NuGet Package fm.Extensions.Testing.DependencyInjection

Provides a base class for tests based on Microsoft.Extensions.DependencyInjection.

Use common Startup.cs patterns like ConfigureConfiguration(...), ConfigureServices(...) and Configure(...) to setup your tests.

Commonly used types:
ServiceTestsBase

Example:
[TestClass]
public sealed class ExampleTests : ServiceTestsBase
{
protected override void ConfigureConfiguration([NotNull] IConfigurationBuilder configuration)
{
base.ConfigureConfiguration(configuration);

// Add additional configuration here
configuration.AddInMemoryCollection(new[]
{
new KeyValuePair("ConfigKey", "ConfigValue"),
});
}

protected override void ConfigureLogging([NotNull] ILoggingBuilder builder)
{
base.ConfigureLogging(builder);

// Add additional loggers or configuration
builder.AddFilter(logLevel => true);
}

protected override void ConfigureServices([NotNull] IServiceCollection services)
{
base.ConfigureServices(services);

// Configure your services here
// services.AddSingleton();
}

[TestMethod]
public void ExampleTest()
{
// Use your DI container as you would during runtime
// IMyService service = this.GetRequiredService();
}
}.

Info

Version: 5.0.0
Author(s): freeMartin
Last Update: Sunday, November 15, 2020
.NET Fiddle: Create the first Fiddle
Project Url: https://www.nuget.org/packages/fm.Extensions.Testing.DependencyInjection
NuGet Url: https://www.nuget.org/packages/fm.Extensions.Testing.DependencyInjection


Install
Install-Package fm.Extensions.Testing.DependencyInjection
dotnet add package fm.Extensions.Testing.DependencyInjection
paket add fm.Extensions.Testing.DependencyInjection
fm.Extensions.Testing.DependencyInjection Download (Unzip the "nupkg" after downloading)



Tags



STATS

must-have-score

2.5

avg-downloads-per-day

6

days-since-last-release

70