From f7ef25e14bba44c0322ff859679d34b94a1e6b98 Mon Sep 17 00:00:00 2001 From: Eric Sibly Date: Sun, 23 Mar 2025 10:12:05 -0700 Subject: [PATCH] v5.4.6 - *Fixed:* Added `TestFrameworkImplementor.SetLocalCreateFactory` to Xunit `ApiTestFixture` constructor to ensure set correctly for the `OnConfiguration` method override. --- CHANGELOG.md | 3 +++ Common.targets | 2 +- src/UnitTestEx.Xunit/ApiTestFixture.cs | 7 ++++++- tests/UnitTestEx.Xunit.Test/ProductApiTestFixture.cs | 5 +++++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f7f414..511f357 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/Common.targets b/Common.targets index 78a92f8..d2da746 100644 --- a/Common.targets +++ b/Common.targets @@ -1,6 +1,6 @@  - 5.4.5 + 5.4.6 preview Avanade Avanade diff --git a/src/UnitTestEx.Xunit/ApiTestFixture.cs b/src/UnitTestEx.Xunit/ApiTestFixture.cs index 35173c6..4bb7a91 100644 --- a/src/UnitTestEx.Xunit/ApiTestFixture.cs +++ b/src/UnitTestEx.Xunit/ApiTestFixture.cs @@ -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; @@ -18,7 +19,11 @@ public class ApiTestFixture : IDisposable where TEntryPoint : class /// /// Initializes a new instance of the class. /// - public ApiTestFixture() => OnConfiguration(); + public ApiTestFixture() + { + TestFrameworkImplementor.SetLocalCreateFactory(() => new XunitLocalTestImplementor()); + OnConfiguration(); + } /// /// Provides an opportunity to perform initial configuration before use. diff --git a/tests/UnitTestEx.Xunit.Test/ProductApiTestFixture.cs b/tests/UnitTestEx.Xunit.Test/ProductApiTestFixture.cs index 3731999..1ffbf12 100644 --- a/tests/UnitTestEx.Xunit.Test/ProductApiTestFixture.cs +++ b/tests/UnitTestEx.Xunit.Test/ProductApiTestFixture.cs @@ -8,11 +8,16 @@ public class ProductApiTestFixture : ApiTestFixture where TS protected override void OnConfiguration() { + Test.ReplaceSingleton(); + MockHttpClientFactory.Create(); + _counter++; if (_counter > 1) { throw new InvalidOperationException("ProductApiTestFixture should only be instantiated once per test run."); } } + + public class TestSomeSome { } } } \ No newline at end of file