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.4.6
- *Fixed:* Added `TestFrameworkImplementor.SetLocalCreateFactory` to Xunit `ApiTestFixture` constructor to ensure set correctly for the `OnConfiguration` method override.

## v5.4.5
- *Fixed:* Added `TesterBase.JsonMediaTypeNames` which provides a list of valid JSON media types to be used to determine JSON-related payloads in tests.
- *Fixed:* Added Xunit `ApiTestFixture.OnConfiguration` to enable configuration to be perform prior to test execution.
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.4.5</Version>
<Version>5.4.6</Version>
<LangVersion>preview</LangVersion>
<Authors>Avanade</Authors>
<Company>Avanade</Company>
Expand Down
7 changes: 6 additions & 1 deletion src/UnitTestEx.Xunit/ApiTestFixture.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Avanade. Licensed under the MIT License. See https://github.com/Avanade/UnitTestEx

using System;
using UnitTestEx.Abstractions;
using UnitTestEx.AspNetCore;
using UnitTestEx.Xunit.Internal;

Expand All @@ -18,7 +19,11 @@ public class ApiTestFixture<TEntryPoint> : IDisposable where TEntryPoint : class
/// <summary>
/// Initializes a new instance of the <see cref="ApiTestFixture{TEntryPoint}"/> class.
/// </summary>
public ApiTestFixture() => OnConfiguration();
public ApiTestFixture()
{
TestFrameworkImplementor.SetLocalCreateFactory(() => new XunitLocalTestImplementor());
OnConfiguration();
}

/// <summary>
/// Provides an opportunity to perform initial <see cref="Test"/> configuration before use.
Expand Down
5 changes: 5 additions & 0 deletions tests/UnitTestEx.Xunit.Test/ProductApiTestFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@ public class ProductApiTestFixture<TStartup> : ApiTestFixture<TStartup> where TS

protected override void OnConfiguration()
{
Test.ReplaceSingleton<TestSomeSome>();
MockHttpClientFactory.Create();

_counter++;
if (_counter > 1)
{
throw new InvalidOperationException("ProductApiTestFixture should only be instantiated once per test run.");
}
}

public class TestSomeSome { }
}
}
Loading