EDennis.NetCoreTestingUtilities 3.4.6

There is a newer version of this package available.
See the version list below for details.
dotnet add package EDennis.NetCoreTestingUtilities --version 3.4.6                
NuGet\Install-Package EDennis.NetCoreTestingUtilities -Version 3.4.6                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="EDennis.NetCoreTestingUtilities" Version="3.4.6" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EDennis.NetCoreTestingUtilities --version 3.4.6                
#r "nuget: EDennis.NetCoreTestingUtilities, 3.4.6"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install EDennis.NetCoreTestingUtilities as a Cake Addin
#addin nuget:?package=EDennis.NetCoreTestingUtilities&version=3.4.6

// Install EDennis.NetCoreTestingUtilities as a Cake Tool
#tool nuget:?package=EDennis.NetCoreTestingUtilities&version=3.4.6                

EDennis.AspNetCore.Base

A library that facilities creating testable multi-tier applications in ASP.NET Core

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:

  • Parallel Architecture for projects that access databases and projects that only access HTTP endpoints. The repository pattern is used for the former type of project. The typed client pattern is used for the latter type of project. Both patterns provide a useful abstraction layer. Both patterns use dependency injection to give controllers access to service objects -- repos and api clients.
  • Temporal Entities -- entity-framework-driven support for history tables. This support was inspired by SQL Server temporal tables; however, the EF implementation makes it possible to do time-travel queries using entity framework. Several base repository methods are provided to support such queries. In addition, the EF implementation makes it possible to record the user who deleted a record -- something that requires a little more work with SQL Server temporal tables.
  • ApiLauncher -- a main class (and supporting classes) that uses configuration settings to identify, start, and stop one or more web api projects; assign available random port numbers; ensure that the same project api is started only once; and update the BaseAddress of all associated HttpClients (following the typed client pattern). Importantly, the ApiLauncher launches all APIs within the same execution context as the main project, making it possible to debug into the Apis, even during automated integration testing. This utility class is especially helpful when you have multiple APIs that each use IdentityServer.
  • Database Management Interceptors (middleware) that look for special header values in HTTP requests in order to create, select, or discard a specific in-memory database. This middleware makes it possible to perform multiple operations on the same in-memory database accessed indirectly through multiple layers of APIs. The interceptors work with both Swagger spot-testing and automated integration testing.
  • A collection of Base Repository Classes that simplify basic Entity Framework operations but still allows querying via Linq expressions
  • Numerous IServiceCollection Extension Methods that simplify the setup of Dependency Injection for
    • Typed HttpClients
    • DbContexts
    • Repository classes
  • Numerous HttpClient Extension methods that simplify basic Http operations such as posting, putting, deleting, or getting any object of type T
  • Several Security Utilities that perform the following functions:
    • 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.
  • Several Xunit base classes that simplify setup of unit and integration tests of projects that use in-memory databases and ApiLauncher during development.

Associated Projects

  • This project has classes that replace all of the functionality provided by EDennis.EFBase
  • This project is designed to work with EDennis.MigrationsExtensions, which provides assistance in performing Entity Framework migrations. In particular, the library provides a MigrationBuilder extension method called SaveMappings, which saves Table/Class and Column/Property mappings to SQL Server extended properties.
  • This project is designed to work with EDennis.NetCoreTestingUtilities, which provides many helpful classes for performing unit/integration tests.
  • The EDennis.DataScaffolder project provides a WinForms application that generates static data for the "HasData" method. When the EDennis.MigrationsExtensions SaveMappings extension method is used (see above), the static data have correct class names and property names.
Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on EDennis.NetCoreTestingUtilities:

Package Downloads
EDennis.AspNetCore.Base

Alpha version that still requires (a) updated code comments, (b) updated wiki documentation, and (c) completed sample solution

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.8.6 1,212 2/4/2020
3.8.5 718 2/3/2020
3.8.4 734 2/3/2020
3.8.3 942 2/3/2020
3.8.2 812 1/28/2020
3.8.1 650 1/22/2020
3.8.0 696 1/22/2020
3.7.9 851 1/11/2020
3.7.8 801 1/11/2020
3.7.7 728 1/9/2020
3.7.6 800 1/9/2020
3.7.5 785 1/9/2020
3.7.4 750 1/9/2020
3.7.3 709 1/9/2020
3.7.2 787 1/4/2020
3.7.1 725 1/2/2020
3.7.0 658 1/2/2020
3.6.7 774 12/19/2019
3.6.6 721 12/19/2019
3.6.5 760 12/18/2019
3.6.4 723 12/12/2019
3.6.3 702 12/12/2019
3.6.2 666 12/12/2019
3.6.1 709 12/10/2019
3.6.0 723 10/22/2019
3.5.0 710 10/8/2019
3.4.8 801 9/12/2019
3.4.7 782 9/10/2019
3.4.6 823 8/16/2019
3.4.5 812 6/21/2019
3.4.3 769 5/7/2019
3.4.2 778 5/7/2019
3.4.1 778 5/3/2019
3.4.0 6,250 3/25/2019
3.3.1 799 3/5/2019
3.3.0 805 3/5/2019
3.2.2 5,111 2/20/2019
3.2.1 812 2/8/2019
3.2.0 894 12/15/2018
3.1.0 1,569 11/19/2018
3.0.0 1,555 9/25/2018
2.9.9 1,500 9/24/2018
2.9.8 1,553 9/24/2018
2.9.7 1,761 9/21/2018
2.9.6 1,640 9/21/2018
2.9.5 1,804 9/21/2018
2.9.4 1,724 9/20/2018
2.9.3 1,735 9/18/2018
2.9.2 1,747 9/18/2018
2.9.1 1,637 9/17/2018
2.9.0 1,570 9/11/2018
2.8.4 1,012 8/16/2018
2.8.3 1,059 8/10/2018
2.8.2 1,079 8/9/2018
2.8.1 1,126 8/9/2018
2.8.0 1,112 8/9/2018
2.7.2 1,088 8/7/2018
2.7.1 1,099 8/7/2018
2.7.0 1,015 8/6/2018
2.6.0 1,068 8/2/2018
2.5.4 1,067 7/23/2018
2.5.3 1,049 7/23/2018
2.5.2 1,173 6/21/2018
2.5.1 1,087 6/15/2018
2.5.0 1,161 6/6/2018
2.4.1 1,092 6/4/2018
2.4.0 1,160 5/25/2018
2.3.9 1,218 5/2/2018
2.3.8 1,187 4/17/2018
2.3.7 1,331 4/6/2018
2.3.6 1,275 3/23/2018
2.3.5 1,165 3/9/2018
2.3.4 1,200 3/9/2018
2.3.3 1,066 3/8/2018
2.3.2 1,078 3/8/2018
2.3.1-alpha 1,137 3/6/2018
2.2.4 1,205 3/3/2018
2.2.3.1 1,216 3/3/2018
2.2.3 1,181 3/3/2018
2.2.2 1,149 2/21/2018
2.2.1 1,157 2/21/2018
2.2.0 1,163 2/10/2018
2.1.1 1,101 2/8/2018
2.1.0.1 1,259 12/21/2017
2.1.0 1,301 12/21/2017
2.0.0 1,169 12/21/2017
1.0.0.1 1,236 12/3/2017
1.0.0 1,584 11/30/2017

Updated TestJson to support decimal places better