Skip to content

Releases: fusonic/dotnet-extensions

7.2.0

28 Jun 11:58
Compare
Choose a tag to compare

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

25 May 12:10
Compare
Choose a tag to compare

Allow types like string to be used as entity key and in the queryable extensions

7.1.1

03 Apr 14:31
Compare
Choose a tag to compare

UnitTests / PostgreSQL: If migrations fail during the template DB creation, the template DB gets dropped.

7.1.0

28 Feb 10:05
Compare
Choose a tag to compare

New features in EF Core unit tests:

  • Added an AggregateTestStore to support multiple test stores at once (docs)
  • Added support for Microsoft SQL Server (docs)

7.0.3

20 Feb 09:25
Compare
Choose a tag to compare

SendEmail now supports formatting the subject using the new optional parameter SubjectFormatParameters

7.0.2

09 Feb 09:17
Compare
Choose a tag to compare

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

26 Jan 15:23
Compare
Choose a tag to compare

Fixed possible deadlock with XUnit sync context when dropping test databases

7.0.0

24 Jan 17:39
Compare
Choose a tag to compare

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 and
  • Fusonic.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 or
  • Fusonic.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 your TestFixture 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 the TestFixture 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.

Email (Fusonic.Extensions.Email)

  • SendEmail.Command got replaced with SendEmail. 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>-extension RequireAsync to IsRequiredAsync, to match the name of the other methods.
  • Added extension IsRequiredAsync for IQueryable<T>. Same as the other methods, it throws an EntityNotFoundException if the query returns no result.

6.2.2

20 Sep 08:35
Compare
Choose a tag to compare
  • Added additional check methods to PathUtil
  • Added samples from unit test blog
  • Updated the OOB Documentation

6.2.1

02 Jun 08:43
Compare
Choose a tag to compare

ContainerJobActivator: Fixed exception when disposing handlers that implemented IAsyncDisposable