Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Needs Unit Tests #4

Open
GaProgMan opened this issue Jun 1, 2017 · 3 comments
Open

Needs Unit Tests #4

GaProgMan opened this issue Jun 1, 2017 · 3 comments

Comments

@GaProgMan
Copy link
Owner

Using the xUnit.NET Test template (dotnet new xunit) add unit tests for the source code in the src directory.

Add the xUnit.NET test library to a directory at the root level (i.e. alongside the src directory) called tests

@GaProgMan GaProgMan self-assigned this Jun 1, 2017
@GaProgMan
Copy link
Owner Author

An xunit test class library has been added. However the services, contexts and helpers need to be mocked to ensure that we are properly testing everything

@GaProgMan
Copy link
Owner Author

GaProgMan commented Jun 20, 2017

Add unit tests for db model to view model mappers (i.e BookViewModelHelper)

Example:

var new dbModel
{
      prop = value,
};
var viewModel = dbToViewModelMapper(dbModel);
Assert.AreEqual(value, viewModel.value, $"{nameof(viewModel.value)} should be mapped correctly.");

@GaProgMan GaProgMan removed their assignment Oct 22, 2017
@GaProgMan
Copy link
Owner Author

Since I've moved this project to .NET core 2.1 (2.1.301), the xunit test runner no longer runs. It quits out with an error:

Detecting target frameworks in dwCheckApi.Tests.csproj...
Building for framework netcoreapp2.1...
dwCheckApi.Tests -> /home/jay/Code/Azure/dwCheckApi/dwCheckApi.Tests/bin/Debug/netcoreapp2.1/dwCheckApi.Tests.dll
Running .NET Core 2.1.0 tests for framework netcoreapp2.1...
It was not possible to find any compatible framework version
The specified framework 'Microsoft.NETCore.App', version '2.1.0' was not found.

This is a known issue and has been reported on the xunit repo. There is currently a work around by using the latest build from MyGet.

I've TEMPORARILY gotten around this by including:

<RuntimeFrameworkVersion>2.1.0-rc1</RuntimeFrameworkVersion>

in the dwCheckApi.Tests.csproj and ensuring that I have the 2.1.0-rc1 SDK and runtime installed:

jay@Omoikane:~$ dotnet --list-sdks
2.1.300-rc1-008673 [/usr/share/dotnet/sdk]
2.1.301 [/usr/share/dotnet/sdk]
jay@Omoikane:~$ dotnet --list-runtimes
Microsoft.AspNetCore.All 2.1.0-rc1-final [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.1 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.0-rc1-final [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.1 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.0-rc1 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.1 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

Doing this allows all unit tests to be run (until a new build of xunit is released to NuGet)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant