Skip to content

This is a exmaple solution for TDD training. A C# port of this sea-tdd-workshop-09-2021

Notifications You must be signed in to change notification settings

kaiwanyawit-chawankul/LoanNaja

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LoanNaja

This is a exmaple solution for TDD training. A C# port of this sea-tdd-workshop-09-2021

Structure

Project Description
LoanNaja.Core Business logic and infrastucture
LoanNaja Web
LoanNaja.Core.Test Test for business logic
LoanNaja.Test Test for controller using mock
LoanNaja.IntegrationTest Integration Test using WebApplicationFactory
LoanNaja.Spec Black box test
LoanNaja.ContractTest Contact test

Useful command

  1. Add a coverlet to your test project

    dotnet add package coverlet.msbuild
    
  2. Check for code coverage percentage

    dotnet test /p:CollectCoverage=true
    
  3. Add a mock for a parent class

    Mock<IDerived> mock = new Mock<IDerived>( MockBehavior.Strict );
    mock.Setup( obj => obj.Value ).Returns( "Derived" );
    mock.As<IBase>().Setup( obj => obj.Value ).Returns( "Base" );
    
  4. Format your C# code using csharpier

    dotnet-csharpier 
  5. Run a server for acceptance tests

    docker build -t loan-naja -f ./src/LoanNaja/Dockerfile .
    docker run -d --name loannaja -p 8080:80 loan-naja:latest
  6. See server logs

    docker logs loannaja
  7. Close a server

    docker stop loannaja
    docker rm loannaja
  8. Check access to your server

    curl http://docker.local:8080
  9. Run test except an acceptance test

    dotnet test --filter "Category!=Spec"
  10. Run acceptance tests

    docker-compose up --exit-code-from acceptancetests
    docker-compose up --exit-code-from acceptancetests --build
    docker-compose up --exit-code-from acceptancetests --no-cache

Need help?

Go check Setup

About

This is a exmaple solution for TDD training. A C# port of this sea-tdd-workshop-09-2021

Topics

Resources

Stars

Watchers

Forks