Quick and dirty project to get my head around C#, how it uses the .NET libraries, compilation on Linux via Mono and some basic testing. ...hopefully.
Majority of my research is in my csharp_notes file.
Emacs config changes can be found in my Github: .emacs repo.
- Make directory:
ProjectName/src/ProjectName/
and rundotnet new console
to initialise the source code folder. - Make directory:
ProjectName/test/ProjectNameTest/
and rundotnet new xunit
to initialise the test code folder. Followed bydotnet add reference ../../src/ProjectName/ProjectName.csproj
to direct the tests at the src code folder.
- Run code:
dotnet run
fromsrc/ProjectName/
folder. - Test code:
dotnet test
fromtest/ProjectNameTest/
folder.
Or use the docker container to do a full development cycle (clean/build/test/publish/run):
- Build and explicitly call the tests with a log folder (NOTE: that
dotnet
only allows for 1 project to be defined, despite myDockerfile
doing globbing for multiple projects):
mkdir ~/logs
cd $(git rev-parse --show-toplevel)/HelloWorld # Go to git root folder.
docker build --target testrunner -t devapp:test # build test runner image.
docker run --rm -v ~/logs:/app/tests/<Project>/TestResults devapp:test # runs the test runner instance with log output.
- Build/test/publish all within the docker build and then call the app via run command:
cd $(git rev-parse --show-toplevel)/HelloWorld # Go to git root folder.
docker build -t devapp . # Build docker image (Runs clean/build/test/publish).
docker run --rm devapp -- [args] # Runs an instance which implicitly calls `dotnet run`.
- Added Github: Coverlet to the test project with the following line in
test/
:dotnet add package coverlet.msbuild
. - To do a coverage test run:
dotnet test /p:CollectCoverage=true
. - Can change output format (eg. Lcov for emacs Github: coverlay mode support) / excluded files / coverage file destination, easily.
- Actively developed.
Travis is configured to build the Docker container.