Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
2 changes: 1 addition & 1 deletion Common.targets
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>5.6.0</Version>
<Version>5.6.1</Version>
<LangVersion>preview</LangVersion>
<Authors>Avanade</Authors>
<Company>Avanade</Company>
Expand Down
10 changes: 7 additions & 3 deletions src/UnitTestEx/Expectations/ValueExpectations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class ValueExpectations<TTester>(TesterBase owner, TTester tester) : Expe
{
private const string NullJson = "null";
private Func<TTester, string>? _json;
private bool _expectNull;
private bool _expectNull = true;

/// <inheritdoc/>
public override string Title => "Value expectations";
Expand All @@ -27,7 +27,11 @@ public class ValueExpectations<TTester>(TesterBase owner, TTester tester) : Expe
/// Expects that the result JSON compares to the expected <paramref name="json"/>.
/// </summary>
/// <param name="json">The expected JSON function.</param>
public void SetExpectJson(Func<TTester, string> json) => _json = json ?? throw new ArgumentNullException(nameof(json));
public void SetExpectJson(Func<TTester, string> json)
{
_json = json ?? throw new ArgumentNullException(nameof(json));
_expectNull = false;
}

/// <summary>
/// Expects the the result JSON is <c>null</c>.
Expand Down Expand Up @@ -79,7 +83,7 @@ protected async override Task OnAssertAsync(AssertArgs args)
/// <inheritdoc/>
protected override Task OnLastAssertAsync(AssertArgs args)
{
if (!ValueMatched)
if (!_expectNull && !ValueMatched)
args.Tester.Implementor.AssertFail($"Expected value; however, none was returned.");

return Task.CompletedTask;
Expand Down
4 changes: 3 additions & 1 deletion src/UnitTestEx/TestSetUp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,12 @@ public static IConfiguration GetConfiguration(string? environmentVariablePrefix
/// <param name="implementor">The <see cref="TestFrameworkImplementor"/>.</param>
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();
Expand Down
Loading