diff --git a/src/Email/test/Email.Tests.csproj b/src/Email/test/Email.Tests.csproj index ac8f2e5..7033f6d 100644 --- a/src/Email/test/Email.Tests.csproj +++ b/src/Email/test/Email.Tests.csproj @@ -14,6 +14,7 @@ + all diff --git a/src/Email/test/TestBase.cs b/src/Email/test/TestBase.cs index 0a6a7f8..e585ead 100644 --- a/src/Email/test/TestBase.cs +++ b/src/Email/test/TestBase.cs @@ -1,8 +1,10 @@ // Copyright (c) Fusonic GmbH. All rights reserved. // Licensed under the MIT License. See LICENSE file in the project root for license information. +using System.Diagnostics; using Fusonic.Extensions.UnitTests; using Fusonic.Extensions.UnitTests.SimpleInjector; +using MediatR; namespace Fusonic.Extensions.Email.Tests; @@ -17,4 +19,9 @@ public abstract class TestBase : DependencyInjectionUnitTest { protected TestBase(TFixture fixture) : base(fixture) { } + + /// Runs a mediator command in its own scope. Used to reduce possible side effects from test data creation and the like. + [DebuggerStepThrough] + protected Task SendAsync(IRequest request) + => ScopedAsync(() => GetInstance().Send(request)); } diff --git a/src/Hangfire/test/TestBase.cs b/src/Hangfire/test/TestBase.cs index 04ab908..7fe37e7 100644 --- a/src/Hangfire/test/TestBase.cs +++ b/src/Hangfire/test/TestBase.cs @@ -1,7 +1,9 @@ // Copyright (c) Fusonic GmbH. All rights reserved. // Licensed under the MIT License. See LICENSE file in the project root for license information. +using System.Diagnostics; using Fusonic.Extensions.UnitTests.EntityFrameworkCore; +using MediatR; namespace Fusonic.Extensions.Hangfire.Tests; @@ -16,4 +18,9 @@ public abstract class TestBase : DatabaseUnitTest Runs a mediator command in its own scope. Used to reduce possible side effects from test data creation and the like. + [DebuggerStepThrough] + protected Task SendAsync(IRequest request) + => ScopedAsync(() => GetInstance().Send(request)); } \ No newline at end of file diff --git a/src/UnitTests.EntityFrameworkCore/test/UnitTests.EntityFrameworkCore.Tests.csproj b/src/UnitTests.EntityFrameworkCore/test/UnitTests.EntityFrameworkCore.Tests.csproj index f94fba1..fbb9d45 100644 --- a/src/UnitTests.EntityFrameworkCore/test/UnitTests.EntityFrameworkCore.Tests.csproj +++ b/src/UnitTests.EntityFrameworkCore/test/UnitTests.EntityFrameworkCore.Tests.csproj @@ -14,6 +14,7 @@ + runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/UnitTests/src/DependencyInjectionUnitTest.cs b/src/UnitTests/src/DependencyInjectionUnitTest.cs index dd381d7..ff3020e 100644 --- a/src/UnitTests/src/DependencyInjectionUnitTest.cs +++ b/src/UnitTests/src/DependencyInjectionUnitTest.cs @@ -2,22 +2,15 @@ // Licensed under the MIT License. See LICENSE file in the project root for license information. using System.Diagnostics; -using MediatR; using Xunit; namespace Fusonic.Extensions.UnitTests; -public abstract class DependencyInjectionUnitTest : IDisposable, IClassFixture +public abstract class DependencyInjectionUnitTest(TFixture fixture) : IDisposable, IClassFixture where TFixture : class, IDependencyInjectionTestFixture { - private object currentScope; - protected TFixture Fixture { get; } - - protected DependencyInjectionUnitTest(TFixture fixture) - { - Fixture = fixture; - currentScope = fixture.BeginScope(); - } + private object currentScope = fixture.BeginScope(); + protected TFixture Fixture { get; } = fixture; /// Gets an instance of the requested service. [DebuggerStepThrough] @@ -28,11 +21,6 @@ protected T GetInstance() [DebuggerStepThrough] protected object GetInstance(Type serviceType) => Fixture.GetInstance(currentScope, serviceType); - /// Runs a mediator command in its own scope. Used to reduce possible side effects from test data creation and the like. - [DebuggerStepThrough] - protected Task SendAsync(IRequest request) - => ScopedAsync(() => GetInstance().Send(request)); - /// [DebuggerStepThrough] protected TResult Scoped(Func action) diff --git a/src/UnitTests/src/UnitTests.csproj b/src/UnitTests/src/UnitTests.csproj index 6447d13..05a9a78 100644 --- a/src/UnitTests/src/UnitTests.csproj +++ b/src/UnitTests/src/UnitTests.csproj @@ -17,7 +17,6 @@ - @@ -25,8 +24,6 @@ - -