I use to test coverage NUnit test framework and FluentAssertion for both type of testing. All type of test placed inside Tests
directory.
- Test
- Integration
- AppData
: Directory contains test data for feeding test server MongoDB
- ApplicationFactories
: Directory contains object for create test server application
- Fixtures
: Directory contains test fixtures
- Helpers
: Directory contains tools and objects use in test
- Tests
: Directory contains test cases
Integration tests are free of network dependencies. For example if some reasons can broke connection with MongoDB server or MongoDB server will be unreachable then Integration test will be work. For those reasons tests use external package Mongo2Go
For calculate code coverage was used Coverlet and for generating report human readable was used ReportGenerator. For create coverage report you have to use script:
For Windows platform
C:repos\hotdesk-planner> .\scripts\win\code-coverage.ps1
Reports
Script generate two versions of code coverage: HTML and XML. Both versions placed inside ./.coverage/reports/
directory.
- Test
- Unit
- Api
: Directory contains test cases for project Api
- Core
: Directory contains test cases for project Core
- Infrastructure
: Directory contains test cases for project Infrastructure
- Helpers
: Directory contains tools and objects use in test
- AppData
: Directory contains test data for feeding tests
Service use FluentValidation
for validating data models before run any action with repository.
All Validators you find in Core.Validators
. Any information about external package for validating use in project you able to read: https://docs.fluentvalidation.net/en/latest/index.html
Service has defined rules of set depends what action you need to execute:
- Core.Enums.ValidationModelType.GetOne
- Core.Enums.ValidationModelType.Insert
- Core.Enums.ValidationModelType.Update
- Core.Enums.ValidationModelType.Delete
You able to create manual docker image with service from source. Below you find command with description
docker build -t helpdesk-service/dev \
--build-arg SERVICE_BUILD_PLAN=Debug \
--build-arg SERVICE_PORT=3002 \
--build-arg SERVICE_ENV=Development \
--build-arg SERVICE_URL=http://+:3002 .
Build arguments
- SERVICE_BUILD_PLAN You can choose between Debug or Release
- SERVICE_PORT Define for which port service will be available
- SERVICE_ENV Define is it Production or Development environment
- SERVICE_URL Define for which url service should listening
You able create manual docker container with service. Below you will find command:
docker run -d -p 3002:3002 --name service-name helpdesk-service/dev
For windows:
./scripts/win/build-image.ps1 [-env [Development|Production]] [-port [0-9+]] [-args [*]]
List of parameters:
- -env - Define environment. Default: Production
- -port - Define port for which service should listening. Default: 3000
- -args - Define additional arguments.
Example:
./scripts/win/build-image.ps1 -env Development -port 3001
For windows:
./scripts/win/create-image.ps1 -name [*] [[-env [Production|Development]] [-port [0-9+]] [-build-image 0|1]]
List of parameters:
- -name - Define service name for docker. Required
- -env - Define environment. Default: Production
- -port - Define port for which service should listening. Default: 3000
- -buildImage - If image does not exist then first build the image and next the container.
Example:
./scripts/win/create-image.ps1 `
-name SomeService `
-env Development `
-port 3001