Definition
Assembly: CloudNimble.Breakdance.AspNetCore.dll Namespace: CloudNimble.Breakdance.AspNetCore Inheritance: CloudNimble.Breakdance.AspNetCore.AspNetCoreBreakdanceTestBaseSyntax
Summary
A base class for building unit tests for AspNetCore APIs that automatically maintains a TestServer with configuration and a Dependency Injection containers for you.Type Parameters
TStartup-
Constructors
.ctor
Creates a new AspNetCoreBreakdanceTestBase instance.Syntax
Remarks
The call to .Configure() with no content is required to get a minimal, empty IWebHost..ctor Inherited
Inherited from
CloudNimble.Breakdance.AspNetCore.AspNetCoreBreakdanceTestBaseSyntax
Remarks
Uses the modern IHostBuilder pattern for web hosting instead of the deprecated WebHostBuilder.Properties
TestHostBuilder Inherited
Inherited from
CloudNimble.Breakdance.AspNetCore.AspNetCoreBreakdanceTestBaseSyntax
Property Value
Type:Microsoft.Extensions.Hosting.IHostBuilder
TestServer Inherited
Inherited from
CloudNimble.Breakdance.AspNetCore.AspNetCoreBreakdanceTestBaseSyntax
Property Value
Type:Microsoft.AspNetCore.TestHost.TestServer
Methods
AddApis Inherited
Inherited from
CloudNimble.Breakdance.AspNetCore.AspNetCoreBreakdanceTestBaseSyntax
Parameters
| Name | Type | Description |
|---|---|---|
options | System.Action<Microsoft.AspNetCore.Mvc.MvcOptions> | - |
app | System.Action<Microsoft.AspNetCore.Builder.IApplicationBuilder> | - |
Remarks
Calls AddControllers() on the IServiceCollection which does the following, according to the Microsoft docs: combines the effects of Microsoft.Extensions.DependencyInjection.MvcCoreServiceCollectionExtensions.AddMvcCore(Microsoft.Extensions.DependencyInjection.IServiceCollection), Microsoft.Extensions.DependencyInjection.MvcApiExplorerMvcCoreBuilderExtensions.AddApiExplorer(Microsoft.Extensions.DependencyInjection.IMvcCoreBuilder), Microsoft.Extensions.DependencyInjection.MvcCoreMvcCoreBuilderExtensions.AddAuthorization(Microsoft.Extensions.DependencyInjection.IMvcCoreBuilder), Microsoft.Extensions.DependencyInjection.MvcCorsMvcCoreBuilderExtensions.AddCors(Microsoft.Extensions.DependencyInjection.IMvcCoreBuilder), Microsoft.Extensions.DependencyInjection.MvcDataAnnotationsMvcCoreBuilderExtensions.AddDataAnnotations(Microsoft.Extensions.DependencyInjection.IMvcCoreBuilder), and Microsoft.Extensions.DependencyInjection.MvcCoreMvcCoreBuilderExtensions.AddFormatterMappings(Microsoft.Extensions.DependencyInjection.IMvcCoreBuilder).AddMinimalMvc Inherited
Inherited from
CloudNimble.Breakdance.AspNetCore.AspNetCoreBreakdanceTestBaseSyntax
Parameters
| Name | Type | Description |
|---|---|---|
options | System.Action<Microsoft.AspNetCore.Mvc.MvcOptions> | - |
app | System.Action<Microsoft.AspNetCore.Builder.IApplicationBuilder> | - |
Remarks
Calls AddMvcCore() on the IServiceCollection which does the following, according to the Microsoft docs: will register the minimum set of services necessary to route requests and invoke controllers. It is not expected that any application will satisfy its requirements with just a call to Microsoft.Extensions.DependencyInjection.MvcCoreServiceCollectionExtensions.AddMvcCore(Microsoft.Extensions.DependencyInjection.IServiceCollection). Additional configuration using the Microsoft.Extensions.DependencyInjection.IMvcCoreBuilder will be required.AddRazorPages Inherited
Inherited from
CloudNimble.Breakdance.AspNetCore.AspNetCoreBreakdanceTestBaseSyntax
Parameters
| Name | Type | Description |
|---|---|---|
options | System.Action<Microsoft.AspNetCore.Mvc.RazorPages.RazorPagesOptions> | - |
app | System.Action<Microsoft.AspNetCore.Builder.IApplicationBuilder> | - |
Remarks
Calls AddRazorPages() on the IServiceCollection which does the following, according to the Microsoft docs: combines the effects of Microsoft.Extensions.DependencyInjection.MvcCoreServiceCollectionExtensions.AddMvcCore(Microsoft.Extensions.DependencyInjection.IServiceCollection), Microsoft.Extensions.DependencyInjection.MvcCoreMvcCoreBuilderExtensions.AddAuthorization(Microsoft.Extensions.DependencyInjection.IMvcCoreBuilder), Microsoft.Extensions.DependencyInjection.MvcDataAnnotationsMvcCoreBuilderExtensions.AddDataAnnotations(Microsoft.Extensions.DependencyInjection.IMvcCoreBuilder), Microsoft.Extensions.DependencyInjection.TagHelperServicesExtensions.AddCacheTagHelper(Microsoft.Extensions.DependencyInjection.IMvcCoreBuilder), and Microsoft.Extensions.DependencyInjection.MvcRazorPagesMvcCoreBuilderExtensions.AddRazorPages(Microsoft.Extensions.DependencyInjection.IMvcCoreBuilder).AddViews Inherited
Inherited from
CloudNimble.Breakdance.AspNetCore.AspNetCoreBreakdanceTestBaseSyntax
Parameters
| Name | Type | Description |
|---|---|---|
options | System.Action<Microsoft.AspNetCore.Mvc.MvcOptions> | - |
app | System.Action<Microsoft.AspNetCore.Builder.IApplicationBuilder> | - |
Remarks
Calls AddControllersWithViews() on the IServiceCollection which does the following, according to the Microsoft docs: combines the effects of Microsoft.Extensions.DependencyInjection.MvcCoreServiceCollectionExtensions.AddMvcCore(Microsoft.Extensions.DependencyInjection.IServiceCollection), Microsoft.Extensions.DependencyInjection.MvcApiExplorerMvcCoreBuilderExtensions.AddApiExplorer(Microsoft.Extensions.DependencyInjection.IMvcCoreBuilder), Microsoft.Extensions.DependencyInjection.MvcCoreMvcCoreBuilderExtensions.AddAuthorization(Microsoft.Extensions.DependencyInjection.IMvcCoreBuilder), Microsoft.Extensions.DependencyInjection.MvcCorsMvcCoreBuilderExtensions.AddCors(Microsoft.Extensions.DependencyInjection.IMvcCoreBuilder), Microsoft.Extensions.DependencyInjection.MvcDataAnnotationsMvcCoreBuilderExtensions.AddDataAnnotations(Microsoft.Extensions.DependencyInjection.IMvcCoreBuilder), Microsoft.Extensions.DependencyInjection.MvcCoreMvcCoreBuilderExtensions.AddFormatterMappings(Microsoft.Extensions.DependencyInjection.IMvcCoreBuilder), Microsoft.Extensions.DependencyInjection.TagHelperServicesExtensions.AddCacheTagHelper(Microsoft.Extensions.DependencyInjection.IMvcCoreBuilder), Microsoft.Extensions.DependencyInjection.MvcViewFeaturesMvcCoreBuilderExtensions.AddViews(Microsoft.Extensions.DependencyInjection.IMvcCoreBuilder), and Microsoft.Extensions.DependencyInjection.MvcRazorMvcCoreBuilderExtensions.AddRazorViewEngine(Microsoft.Extensions.DependencyInjection.IMvcCoreBuilder).AssemblySetup Override
Inherited from
CloudNimble.Breakdance.AspNetCore.AspNetCoreBreakdanceTestBaseSyntax
Remarks
With MSTest, use [AssemblyInitialize]. With NUnit, use [OneTimeSetup]. With xUnit, good luck: https://xunit.net/docs/shared-contextAssemblySetupAsync Inherited Virtual
Inherited from
CloudNimble.Breakdance.AspNetCore.AspNetCoreBreakdanceTestBaseSyntax
Returns
Type:System.Threading.Tasks.Task
Remarks
With MSTest, use [AssemblyInitialize]. With NUnit, use [OneTimeSetUp]. With xUnit, good luck: https://xunit.net/docs/shared-contextEnsureTestServer Inherited
Inherited from
CloudNimble.Breakdance.AspNetCore.AspNetCoreBreakdanceTestBaseSyntax
Remarks
Builds the host using IHostBuilder, starts it, and retrieves the AspNetCoreBreakdanceTestBase.TestServer from the host services.EnsureTestServerAsync Inherited
Inherited from
CloudNimble.Breakdance.AspNetCore.AspNetCoreBreakdanceTestBaseSyntax
Returns
Type:System.Threading.Tasks.Task
Remarks
Builds the host using IHostBuilder, starts it, and retrieves the AspNetCoreBreakdanceTestBase.TestServer from the host services.GetHttpClient Inherited
Inherited from
CloudNimble.Breakdance.AspNetCore.AspNetCoreBreakdanceTestBaseSyntax
Parameters
| Name | Type | Description |
|---|---|---|
routePrefix | string | The string to append to the BaseAddress for all requests. Defaults to WebApiConstants.RoutePrefix. |
Returns
Type:System.Net.Http.HttpClient
A properly configured HttpClientinstance from the AspNetCoreBreakdanceTestBase.TestServer.
GetHttpClient Inherited
Inherited from
CloudNimble.Breakdance.AspNetCore.AspNetCoreBreakdanceTestBaseSyntax
Parameters
| Name | Type | Description |
|---|---|---|
authHeader | System.Net.Http.Headers.AuthenticationHeaderValue | - |
routePrefix | string | The string to append to the BaseAddress for all requests. Defaults to WebApiConstants.RoutePrefix. |
Returns
Type:System.Net.Http.HttpClient
A properly configured HttpClientinstance from the AspNetCoreBreakdanceTestBase.TestServer.
GetKeyedService Override
Inherited from
CloudNimble.Breakdance.AspNetCore.AspNetCoreBreakdanceTestBaseSyntax
Parameters
| Name | Type | Description |
|---|---|---|
key | string | The key of the service to get. |
Returns
Type:T
A service object of type T.
Type Parameters
T- The type of service object to get.
GetKeyedServices Override
Inherited from
CloudNimble.Breakdance.AspNetCore.AspNetCoreBreakdanceTestBaseSyntax
Parameters
| Name | Type | Description |
|---|---|---|
key | string | The |
Returns
Type:System.Collections.Generic.IEnumerable<T>
An IEnumerable`1 of type T.
Type Parameters
T- The type of service object to get.
GetService Override
Inherited from
CloudNimble.Breakdance.AspNetCore.AspNetCoreBreakdanceTestBaseSyntax
Returns
Type:T
A service object of type T.
Type Parameters
T- The type of service object to get.
GetServices Override
Inherited from
CloudNimble.Breakdance.AspNetCore.AspNetCoreBreakdanceTestBaseSyntax
Returns
Type:System.Collections.Generic.IEnumerable<T>
An enumeration of services of type T.
Type Parameters
T- The type of service object to get.
TestSetup Override
Inherited from
CloudNimble.Breakdance.AspNetCore.AspNetCoreBreakdanceTestBaseSyntax
Remarks
With MSTest, use [TestInitialize]. With NUnit, use [Setup]. With xUnit, good luck: https://xunit.net/docs/shared-contextTestSetupAsync Inherited Virtual
Inherited from
CloudNimble.Breakdance.AspNetCore.AspNetCoreBreakdanceTestBaseSyntax
Returns
Type:System.Threading.Tasks.Task
Remarks
With MSTest, use [TestInitialize]. With NUnit, use [SetUp]. With xUnit, good luck: https://xunit.net/docs/shared-contextTestTearDown Override
Inherited from
CloudNimble.Breakdance.AspNetCore.AspNetCoreBreakdanceTestBase