Releases: fusonic/dotnet-extensions
7.2.0
Changes
Untied razor view rendering logic from email-specific rendering.
The lib Fusonic.Extensions.Email contained a renderer for Razor views, that was directly tied to the emails. This renderer was extracted and moved to Fusonic.Extensions.AspNetCore.Razor.
7.1.2
Allow types like string to be used as entity key and in the queryable extensions
7.1.1
UnitTests / PostgreSQL: If migrations fail during the template DB creation, the template DB gets dropped.
7.1.0
7.0.3
SendEmail now supports formatting the subject using the new optional parameter SubjectFormatParameters
7.0.2
Fixes
Database unit tests with PostgreSQL could still cause deadlocks within the XUnit synchronisation context. This is now fixed by enforcing .ConfigureAwait(false)
in the whole Npgsql-Testing project.
7.0.1
Fixed possible deadlock with XUnit sync context when dropping test databases
7.0.0
The update to .NET7 contains breaking changes.
Replaced libraries
Validation
The libraries Fusonic.Extensions.Validation
and Fusonic.Extensions.Validation.Mvc
got removed.
Those libraries were initially used for model validation of MediatR-requests.
Replacement: A decorator was introduced in Fusonic.Extensions.AspNetCore
, which uses the much faster ObjectModelValidator
from AspNetCore.Mvc
. See docs/AspNetCore/README.md#validation-of-mediatr-requests for details.
Unit testing
The method how unit tests are done got revised. The support for having attributes for switching between InMemory tests and tests against real databases has been dropped completely. Instead it is highly recommended to switch to virtualized (Docker) database instances for testing, that use tmpfs
, an in-memory file system, for the data partition. See https://www.fusonic.net/de/blog/fusonic-test-with-databases-part-3 for technical details.
Removed libraries
All (but one) unit test libraries got replaced with a simplified version. The following libraries got removed:
Fusonic.Extensions.UnitTests.Adapters.EntityFrameworkCore
Fusonic.Extensions.UnitTests.Adapters.InMemoryDatabase
Fusonic.Extensions.UnitTests.Adapters.PostgreSql
Fusonic.Extensions.UnitTests.Tools.PostgreSql
Fusonic.Extensions.XUnit
Removed dotnet tools without replacement
The dotnet tool pgtestutil
got removed. Uninstall it with
dotnet tool uninstall --global Fusonic.Extensions.UnitTests.Tools.PostgreSql
Removed XUnit extensions without replacement
XUnit extensions provided
- a test context
- a lifetime scope for SimpleInjector that spanned the execution of a test (
container.RegisterTestScoped<T>
) - the
FusonicTestFrameworkAttribute
Remove the FusonicTestFrameworkAttribute
from your source. It's not required/existing anymore. Usually you just delete your AssemblyInfo.cs
for that.
You can usually replace your RegisterTestScoped
with RegisterSingleton
and reset those registered services in the test constructor.
Example:
// Old implementation
public class SomeTest : TestBase<SomeTest.SomeTestFixture>
{
// Test code ...
public SomeTestFixture : TestFixture
{
public void RegisterDependencies(Container container)
=> container.RegisterTestScoped(() => Substitute.For<ISomeInterface>());
}
}
// New implementation
public class SomeTest : TestBase<SomeTest.SomeTestFixture>
{
public SomeTest()
=> GetInstance<ISomeInterface>().CleanSubstitute();
// Test code ...
public SomeTestFixture : TestFixture
{
public void RegisterDependencies(Container container)
=> container.RegisterSingleton(() => Substitute.For<ISomeInterface>());
}
}
Removed EF Core InMemoryDatabase support without replacement
Support for EFs InMemory prvovider was dropped. While discouraged, if you still need it, you can easily implement the new ITestStore
supporting the InMemory provider.
Replacements
For database testing support with EF Core you now use
Fusonic.Extensions.UnitTests.EntityFrameworkCore
andFusonic.Extensions.UnitTests.EntityFrameworkCore.Npgsql
For details see docs/UnitTests/Database setup.
Base classes / DI container dependencies
SimpleInjector is no dependency for the base classes anymore. To get support for a specific DI container, use
Fusonic.Extensions.UnitTests.SimpleInjector
orFusonic.Extensions.UnitTests.ServiceProvider
The base class UnitTest
got renamed to DependencyInjectionUnitTest
.
The base class UnitTestFixture
got renamed to DependencyInjectionTestFixture
with the DI container specific implementations SimpleInjectorTestFixture
and ServiceProviderTestFixture
.
For details see docs/UnitTests/Setup.
In a nutshell
- Test database creation:
ITestDatabaseTemplateCreator
has been removed. Create the template directly in yourTestFixture
in your first test run or use a console app for creating the test database. See docs/UnitTests/PostgreSQL - Template for details. - Attributes for defining the database, like
[InMemoryTest]
or[PostgreSqlTest]
have been removed without replacement. - Removed previously required assembly attribute
FusonicTestFramework
- Renamed base classes (Depending on your needs:
DatabaseUnitTest
,DependencyInjectionUnitTest
,SimpleInjectorTestFixture
,ServiceProviderTestFixture
) - Database configuration is highly simplified.
- The previous
ConfigureDatabaseProviders
-override in theTestFixture
can be removed - You now need to register an
ITestStore
that handles your test databases. - You now register the AppDbContext like in your app, via
services.AddDbContext<T>(...)
- If you have a test registration like
services.AddSingleton(_ => container.GetInstance<AppDbContext>())
, remove it. It will cause a circular dependency in your test registration. - See docs/UnitTests/PostgreSQL - Configure DbContext for details.
- The previous
Email (Fusonic.Extensions.Email)
SendEmail.Command
got replaced withSendEmail
. The previous 5 constructors got replaced with a single constructor with some required and a few optional fields.- Additional attachment resolvers now have to be registered with
container.Collections.Append<IEmailAttachmentResolver, YourResolver>()
- The
IEmailAttachmentResolver
interface changed.
Entity framework abstractions
IEntity
and EntityNotFoundException
got moved from Fusonic.Extensions.EntityFrameworkCore/Domain
to Fusonic.Extensions.Common/Entities
Entity framwork extensions
- Unified naming of
DbSet<T>
-extensionRequireAsync
toIsRequiredAsync
, to match the name of the other methods. - Added extension
IsRequiredAsync
forIQueryable<T>
. Same as the other methods, it throws anEntityNotFoundException
if the query returns no result.
6.2.2
- Added additional check methods to PathUtil
- Added samples from unit test blog
- Updated the OOB Documentation
6.2.1
ContainerJobActivator: Fixed exception when disposing handlers that implemented IAsyncDisposable