From 91ab2f9f8d00a392d85f97cfd36c3cea298205b6 Mon Sep 17 00:00:00 2001 From: Ben Mazzarol Date: Sun, 23 Jun 2024 23:04:30 +0800 Subject: [PATCH] chore: improve coverage --- BunsenBurner.Tests/AaaTests.cs | 3 +++ BunsenBurner.Tests/ManualDisposalTests.cs | 24 +++++++++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/BunsenBurner.Tests/AaaTests.cs b/BunsenBurner.Tests/AaaTests.cs index 473dc3e..56c6d24 100644 --- a/BunsenBurner.Tests/AaaTests.cs +++ b/BunsenBurner.Tests/AaaTests.cs @@ -161,6 +161,9 @@ public async Task Case12() async () => await Arrange(() => 1).Act(x => x + 2).Assert(x => x > 4 && x < 6) ); Assert.Equal("x => ((x > 4) AndAlso (x < 6)) is not true for input '3'", exception.Message); + Assert.NotNull(exception.Expression); + Assert.NotNull(exception.Result); + Assert.Null(exception.TestData); } [Fact(DisplayName = "Expression based assertions with data work")] diff --git a/BunsenBurner.Tests/ManualDisposalTests.cs b/BunsenBurner.Tests/ManualDisposalTests.cs index 7f72d1c..e6d10cb 100644 --- a/BunsenBurner.Tests/ManualDisposalTests.cs +++ b/BunsenBurner.Tests/ManualDisposalTests.cs @@ -1,8 +1,5 @@ -using System.Diagnostics.CodeAnalysis; +namespace BunsenBurner.Tests; -namespace BunsenBurner.Tests; - -[SuppressMessage("Major Code Smell", "S3881:\"IDisposable\" should be implemented correctly")] sealed class TestDisposable : IDisposable { public bool IsDisposed; @@ -13,6 +10,17 @@ public void Dispose() } } +sealed class TestAsyncDisposable : IAsyncDisposable +{ + public bool IsDisposed; + + public ValueTask DisposeAsync() + { + IsDisposed = true; + return ValueTask.CompletedTask; + } +} + public static class ManualDisposalTests { [Fact(DisplayName = "Disposal is automatic")] @@ -30,4 +38,12 @@ public static async Task Case2() await disposable.Arrange().Act(d => d).Assert(r => !r.IsDisposed).NoDisposal(); Assert.False(disposable.IsDisposed); } + + [Fact(DisplayName = "Async disposal is automatic")] + public static async Task Case3() + { + var disposable = new TestAsyncDisposable(); + await disposable.Arrange().Act(d => d).Assert(r => !r.IsDisposed); + Assert.True(disposable.IsDisposed); + } }