This project was created by Avanade Team to study
Commands to create a project
dotnet new globaljson --sdk-version 6.0.400
dotnet new webapi --name Potato.Product
https://docs.microsoft.com/en-us/windows/wsl/install
IP Tables to WSL-2
update-alternatives --config iptables
To use in WSL for ELK warmup
sysctl -w vm.max_map_count=262144
Packages
dotnet tool install --global dotnet-reportgenerator-globaltool
dotnet tool install --global dotnet-ef
dotnet tool install --global dotnet-sonarscanner
dotnet tool install --global dotnet-coverage
References
- To create a project:
https://docs.microsoft.com/en-us/dotnet/core/tools/
- To create Application tier
- To create infra.database tier
https://docs.microsoft.com/en-us/ef/core/modeling/
https://docs.microsoft.com/en-us/ef/core/managing-schemas/migrations/?tabs=dotnet-core-cli
Para executar os comandos, esteja na pasta src
dotnet ef migrations add InitDatabase --project Potato.Product.Infra.Database -s Potato.Product.Api -c Potato.Product.Infra.Database.ProductContext --verbose
dotnet ef database update InitDatabase --project Potato.Product.Infra.Database -s Potato.Product.Api -c Potato.Product.Infra.Database.ProductContext --verbose
{
"name": "Kleber Edson",
"description": "dupla de dois",
"url": "http://avanade-estudo.com.br",
"sku": "$#RTGVDF",
"price": 99.33
}
https://reportgenerator.io/
Run tests
$>src> dotnet test Potato.Product.sln /p:CollectCoverage=true /p:CoverletOutput=Results\Coverage /p:CoverletOutputFormat=cobertura
$>src> reportgenerator -reports:**/coverage.cobertura.xml -targetdir:Tests\results\WebResult
#Abre o arquivo no browser padrão
$>src> Tests\results\WebResult\index.html
dotnet sonarscanner begin /k:"PotatoStore" /d:sonar.host.url="http://localhost:9044" /d:sonar.login="YOUR_KEY" /d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml
dotnet build --no-incremental
dotnet-coverage collect 'dotnet test' -f xml -o 'coverage.xml'
dotnet sonarscanner end /d:sonar.login="YOUR_KEY"
refs: https://docs.sonarqube.org/latest/analysis/test-coverage/dotnet-test-coverage/