Initialize Module Project¶
Module template is used to develop reusable application modules or independent services.
First, install the ABP CLI if you haven't installed it before
The abp new
command creates an ABP solution or other artifacts based on an ABP template. ABP CLI has several parameters to create a new ABP solution.
Create new module¶
ModuleS are reusable sub applications used by your main project. Using Module is a best practice if you are building a microservice solution.
Available frontends: MVC
, Angular
, Blazor
Available database providers: Entity Framework Core
, MongoDB
.
abp new-module GridLab.PSSX.ModuleName -u mvc -d ef
Or use abp studio
app
ABP Studio is the easiest way to get started with the empty solution. Remember that, first access to the Studio requires to have an active internet connection, so make sure you are connected to internet.
Solution Structure¶
Based on the options you've specified, you will get a slightly different solution structure. If you don't specify any option, you will have a solution like shown below:
Projects are organized as src
and test
folders:
src
folder contains the actual module which is layered based on DDD principles.test
folder contains unit & integration tests.
The diagram below shows the layers & project dependencies of the module:
Test Projects¶
The solution has multiple test projects, one for each layer:
.Domain.Tests
is used to test the domain layer..Application.Tests
is used to test the application layer..EntityFrameworkCore.Tests
is used to test EF Core configuration and custom repositories..MongoDB.Tests
is used to test MongoDB configuration and custom repositories..TestBase
is a base (shared) project for all tests.
In addition, .HttpApi.Client.ConsoleTestApp
is a console application (not an automated test project) which demonstrate the usage of HTTP APIs from a Dotnet application.
Test projects are prepared for integration testing;
- It is fully integrated to ABP framework and all services in your application.
- It uses SQLite in-memory database for EF Core. For MongoDB, it uses the Mongo2Go library.
- Authorization is disabled, so any application service can be easily used in tests.
You can still create unit tests for your classes which will be harder to write (because you will need to prepare mock/fake objects), but faster to run (because it only tests a single class and skips all initialization process).
Domain & Application tests are using EF Core. If you remove EF Core integration or you want to use MongoDB for testing these layers, you should manually change project references & module dependencies.
How to Configure Nuget?¶
NuGet behavior is controlled by settings in different NuGet.Config
or nuget.config
files as described in Common NuGet configurations.
Get copy of NuGet.Config
from nuget-config project also you can create a new NuGet.Config
under project root directory.