diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ab9645..d206301 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ Represents the **NuGet** versions. +## v5.6.1 +- *Fixed:* The `ValueExpectations` corrected to ensure that the expected value is correctly compared against the actual value. + ## v5.6.0 - *Enhancement:* The `RunAsync` methods updated to support `ValueTask` as well as `Task` for the `TypeTester` and `GenericTester` (.NET 9+ only). - *Enhancement:* Added `HttpResultAssertor` for ASP.NET Minimal APIs `Results` (e.g. `Results.Ok()`, `Results.NotFound()`, etc.) to enable assertions via the `ToHttpResponseMessageAssertor`. diff --git a/Common.targets b/Common.targets index e2f6174..fa1c76e 100644 --- a/Common.targets +++ b/Common.targets @@ -1,6 +1,6 @@  - 5.6.0 + 5.6.1 preview Avanade Avanade diff --git a/src/UnitTestEx/Expectations/ValueExpectations.cs b/src/UnitTestEx/Expectations/ValueExpectations.cs index e018e31..114e158 100644 --- a/src/UnitTestEx/Expectations/ValueExpectations.cs +++ b/src/UnitTestEx/Expectations/ValueExpectations.cs @@ -18,7 +18,7 @@ public class ValueExpectations(TesterBase owner, TTester tester) : Expe { private const string NullJson = "null"; private Func? _json; - private bool _expectNull; + private bool _expectNull = true; /// public override string Title => "Value expectations"; @@ -27,7 +27,11 @@ public class ValueExpectations(TesterBase owner, TTester tester) : Expe /// Expects that the result JSON compares to the expected . /// /// The expected JSON function. - public void SetExpectJson(Func json) => _json = json ?? throw new ArgumentNullException(nameof(json)); + public void SetExpectJson(Func json) + { + _json = json ?? throw new ArgumentNullException(nameof(json)); + _expectNull = false; + } /// /// Expects the the result JSON is null. @@ -79,7 +83,7 @@ protected async override Task OnAssertAsync(AssertArgs args) /// protected override Task OnLastAssertAsync(AssertArgs args) { - if (!ValueMatched) + if (!_expectNull && !ValueMatched) args.Tester.Implementor.AssertFail($"Expected value; however, none was returned."); return Task.CompletedTask; diff --git a/src/UnitTestEx/TestSetUp.cs b/src/UnitTestEx/TestSetUp.cs index de0701c..3046a27 100644 --- a/src/UnitTestEx/TestSetUp.cs +++ b/src/UnitTestEx/TestSetUp.cs @@ -114,10 +114,12 @@ public static IConfiguration GetConfiguration(string? environmentVariablePrefix /// The . public static void LogAutoSetUpOutputs(TestFrameworkImplementor implementor) { + var now = DateTime.UtcNow; + // Top-level test dividing line! implementor.WriteLine(""); implementor.WriteLine(new string('=', 80)); - implementor.WriteLine($"Timestamp: {DateTime.UtcNow} (UTC)."); + implementor.WriteLine($"Timestamp: {now.ToLocalTime()} (local) / {now} (UTC)."); // Output any previously registered auto set up outputs. var output = GetAutoSetUpOutput();