fm.Extensions.Testing.DependencyInjection.MSTest
5.0.0
Provides a MSTest base class for tests based on Microsoft.Extensions.DependencyInjection. Use common Startup.cs patterns like ConfigureServices(...) and Configure(...) to setup your tests.
This extends ServiceTestsBase by adding the TestContext properties to configuration and enabling TestContext logging.
Commonly used types:
ServiceTests
Examples see https://www.nuget.org/packages/fm.Extensions.Testing.DependencyInjection
[TestClass]
public sealed class ExampleTests : ServiceTests
{
protected override void ConfigureConfiguration([NotNull] IConfigurationBuilder configuration)
{
base.ConfigureConfiguration(configuration);
// Add additional configuration here
configuration.AddInMemoryCollection(new[]
{
new KeyValuePair<string, string>("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<IMyService, MyService>();
}
[TestMethod]
public void ExampleTest()
{
// Use your DI container as you would during runtime
// IMyService service = this.GetRequiredService<IMyService>();
}
}
Install-Package fm.Extensions.Testing.DependencyInjection.MSTest -Version 5.0.0
dotnet add package fm.Extensions.Testing.DependencyInjection.MSTest --version 5.0.0
<PackageReference Include="fm.Extensions.Testing.DependencyInjection.MSTest" Version="5.0.0" />
paket add fm.Extensions.Testing.DependencyInjection.MSTest --version 5.0.0
#r "nuget: fm.Extensions.Testing.DependencyInjection.MSTest, 5.0.0"
Release Notes
Upgrade to .NET 5.0
Dependencies
-
.NETFramework 4.6.1
- fm.Extensions.Configuration.TestContext (>= 4.0.0)
- fm.Extensions.Logging.TestContext (>= 6.0.0)
- fm.Extensions.Testing.DependencyInjection (>= 5.0.0)
- MSTest.TestFramework (>= 2.1.2)
-
.NETStandard 2.0
- fm.Extensions.Configuration.TestContext (>= 4.0.0)
- fm.Extensions.Logging.TestContext (>= 6.0.0)
- fm.Extensions.Testing.DependencyInjection (>= 5.0.0)
- MSTest.TestFramework (>= 2.1.2)
Used By
NuGet packages (1)
Showing the top 1 NuGet packages that depend on fm.Extensions.Testing.DependencyInjection.MSTest:
Package | Downloads |
---|---|
fm.Extensions.Logging.Testing.MSTest
Logs and reports log messages that have not been handled during UnitTests.
|
GitHub repositories
This package is not used by any popular GitHub repositories.
Version History
Version | Downloads | Last updated |
---|---|---|
5.0.0 | 298 | 11/15/2020 |
4.2.0 | 400 | 1/4/2020 |
4.1.0 | 228 | 10/23/2019 |
4.0.0 | 369 | 9/4/2019 |
4.0.0-preview.2 | 163 | 2/26/2019 |
4.0.0-preview.1 | 148 | 2/26/2019 |
3.0.0 | 5,611 | 10/12/2017 |
2.0.0 | 428 | 10/9/2017 |
1.0.0 | 604 | 2/27/2017 |