EDennis.AspNetCore.Base
1.3.1
See the version list below for details.
dotnet add package EDennis.AspNetCore.Base --version 1.3.1
NuGet\Install-Package EDennis.AspNetCore.Base -Version 1.3.1
<PackageReference Include="EDennis.AspNetCore.Base" Version="1.3.1" />
paket add EDennis.AspNetCore.Base --version 1.3.1
#r "nuget: EDennis.AspNetCore.Base, 1.3.1"
// Install EDennis.AspNetCore.Base as a Cake Addin #addin nuget:?package=EDennis.AspNetCore.Base&version=1.3.1 // Install EDennis.AspNetCore.Base as a Cake Tool #tool nuget:?package=EDennis.AspNetCore.Base&version=1.3.1
EDennis.AspNetCore.Base
A library with many test/sample projects, used as a basis for creating testable three-tier applications
Motivation
ASP.NET Core MVC and Entity Framework Core collectively provide a great framework for development of enterprise applications. That said, developing integration-testable three-tier applications with these technologies can be a little challenging at times. It is relatively easy to create a web application on one server that communicates with web API on another server, which in turn communicates with a database via Entity Framework; however, to set up proper, repeatable integration tests -- those that completely reset the database (whether in-memory or real) after each test -- is not straightforward, especially when dealing with three-tier solutions. Furthermore, to completely reset the database after spot testing via Swagger UI requires some extra set-up work. Collectively, these challenges motivated development of a library to facilitate testable three-tier application development.
Features
The current library has a number of features that assist with application development:
- An action filter that looks for special header values in HTTP requests in order to initialize or reset a test connection or in-memory database. Originally, this action filter fully supported both real databases and in-memory databases; however, only the in-memory databases proved to be reliable with parallel unit/integration testing. (A testing-transaction alternative to in-memory databases is still available, but it should be used only in situations where database locks are not likely -- e.g., spot testing using Swagger.)
- An ApiLauncher class that uses appsettings.json to identify, start, and stop one or more web applications. This utility class makes it easier to start and manage a set of micro-services during both automated integration testing and spot-testing (e.g., using Swagger).
- A base repository class that simplifies basic Entity Framework operations but still allows querying via Linq expressions
- A pair of design-time factory classes that allow code-first migrations without default constructors in the DbContext class. (One of these classes, in combination with the EDennis.MigrationsExtensions NuGet library, supports auto-creation of temporal tables.)
- a MaxPlusOneValueGenerator class that mostly emulates a sequence or identity during testing
- SQL scripts that identify and reset all identity values and sequences in a SQL Server database
- Extensions to IServiceCollection that use Reflection to simplify the setup of Dependency Injection for
- Typed HttpClients
- DbContextPools
- Repository classes
- Extensions to HttpClient that simplify the setup of
- Basic Http operations such as posting, putting, deleting, or getting any object of type T
- Consecutive Http operations such as posting and then getting an object of type T -- making it easier to use HttpClient for testing.
- Two types of Controllers
- RepoController, which is designed to work with one or more repository classes backed by Entity Framework
- ProxyController, which is designed to work with one or more API classes backed by HttpClient instances
- Default security for users and clients
- AutologinMiddleware, which allows configuration of users that can be automatically logged on during different launch configurations
- MockClientAuthorizationMiddleware, which allows configuration of OAuth clients for which access tokens are automatically generated during different launch configurations (especially helpful if you are spot-testing with Swagger)
- AddDefaultAuthorizationPolicyConvention, which automatically adds Authorize policies to controllers and action methods (obviating the need for the Authorize attribute)
- AddClientAuthenticationAndAuthorizationWithDefaultPolicies, which is an IServiceCollection extension method that uses reflection to automatically assign default, scope-defined policies to controllers and action methods.
Constraints
- The ApiLauncher will fail if the target port for an API is unavailable.
- In order for the ApiLauncher to work appropriately with spot-testing a master Api (one that calls other APIs), the master Api must be launched using the project profile (with a port in an acceptable range), rather than using IIS Express. To reset sequences/identities at the end of a spot-testing session, be sure to suspend the application by pressing CTRL-C in the command window, rather than by closing the browser window/tab. (Upon restarting spot-testing, identities and sequences will be reset, just in case.)
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.2 is compatible. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
-
.NETCoreApp 2.2
- EDennis.MigrationsExtensions (>= 1.8.0)
- IdentityModel (>= 4.0.0-bruichladdich)
- Microsoft.AspNetCore.App (>= 2.2.0)
- Microsoft.AspNetCore.Authorization.Policy (>= 2.2.0)
- Microsoft.AspNetCore.SignalR (>= 1.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
3.1.2-alpha | 444 | 3/12/2020 |
3.1.1-alpha | 442 | 2/24/2020 |
3.1.0-alpha | 422 | 2/24/2020 |
2.8.0 | 780 | 10/17/2019 |
2.7.9 | 676 | 10/16/2019 |
2.7.8 | 647 | 10/15/2019 |
2.7.7 | 629 | 10/15/2019 |
2.7.6 | 628 | 10/14/2019 |
2.7.5 | 706 | 9/25/2019 |
2.7.4 | 652 | 9/19/2019 |
2.7.3 | 632 | 9/13/2019 |
2.7.1 | 674 | 9/12/2019 |
2.7.0 | 715 | 9/12/2019 |
2.6.2 | 623 | 9/3/2019 |
2.6.1 | 653 | 9/3/2019 |
2.6.0 | 663 | 8/30/2019 |
2.5.2 | 671 | 7/23/2019 |
2.5.1 | 652 | 7/15/2019 |
2.5.0 | 714 | 7/10/2019 |
2.4.8 | 674 | 6/19/2019 |
2.4.7 | 653 | 6/18/2019 |
2.4.6 | 669 | 6/18/2019 |
2.4.5 | 652 | 6/13/2019 |
2.4.4 | 687 | 6/5/2019 |
2.4.2 | 702 | 5/21/2019 |
2.3.0 | 681 | 5/8/2019 |
2.2.9 | 695 | 5/8/2019 |
2.2.8 | 641 | 5/7/2019 |
2.2.7 | 693 | 5/3/2019 |
2.2.6 | 703 | 5/3/2019 |
2.2.5 | 775 | 5/2/2019 |
2.2.4 | 775 | 5/2/2019 |
2.2.3 | 725 | 4/29/2019 |
2.2.2 | 712 | 4/24/2019 |
2.2.1 | 753 | 4/23/2019 |
2.2.0 | 775 | 4/22/2019 |
2.1.3 | 743 | 4/14/2019 |
2.1.2 | 700 | 4/6/2019 |
2.1.1 | 1,280 | 4/5/2019 |
2.1.0 | 1,268 | 4/3/2019 |
2.0.0 | 1,466 | 4/2/2019 |
1.4.5 | 1,251 | 3/29/2019 |
1.4.4 | 1,452 | 3/28/2019 |
1.4.3 | 1,483 | 3/28/2019 |
1.4.2 | 1,343 | 3/27/2019 |
1.4.1 | 1,485 | 3/26/2019 |
1.4.0 | 1,447 | 3/23/2019 |
1.3.7 | 1,279 | 3/19/2019 |
1.3.6 | 1,486 | 3/18/2019 |
1.3.5 | 1,470 | 3/12/2019 |
1.3.4 | 1,441 | 3/9/2019 |
1.3.3 | 1,395 | 3/8/2019 |
1.3.1 | 941 | 1/18/2019 |
1.3.0 | 909 | 1/18/2019 |
1.2.0 | 896 | 1/16/2019 |
1.1.0 | 805 | 12/28/2018 |
1.0.0 | 876 | 12/26/2018 |
Updated AddClientAuthenticationAndAuthorizationWithDefaultPolicies to work with unit/integration tests (where the calling assembly is the test host).