Solidus.Test
0.1.0
dotnet add package Solidus.Test --version 0.1.0
NuGet\Install-Package Solidus.Test -Version 0.1.0
<PackageReference Include="Solidus.Test" Version="0.1.0" />
<PackageVersion Include="Solidus.Test" Version="0.1.0" />
<PackageReference Include="Solidus.Test" />
paket add Solidus.Test --version 0.1.0
#r "nuget: Solidus.Test, 0.1.0"
#:package Solidus.Test@0.1.0
#addin nuget:?package=Solidus.Test&version=0.1.0
#tool nuget:?package=Solidus.Test&version=0.1.0
Solidus.Test
The test base package that covers common test project boilerplate.
Setup test project
Reference NuGet package
dotnet add package Solidus.TestAdd global usings for convenience
global using Solidus.Test;
Environment Variables usage example
.\.github\workflows\dotnet.yml
...
- name: Test
env:
TEST_HOUSE_NAME: ${{ secrets.TEST_HOUSE_NAME }}
TEST_HOUSE_CONFIGURATION: ${{ vars.TEST_HOUSE_CONFIGURATION }}
run: dotnet test --no-build --verbosity normal
...
.\UnitTests\HouseTest.cs
public class HouseTest : TestBase
{
[Test]
public void HappyPath()
{
// Arrange.
var houseConfiguration = env.ReadJsonFromEnvironmentVariable<HouseConfiguration>("TEST_HOUSE_CONFIGURATION");
var sut = new House();
sut.Name = env.ReadEnvironmentVariable("TEST_HOUSE_NAME");
sut.RoomCount = houseConfiguration.RoomCount;
// Act/Assert.
...
}
}
Mother Factory usage example
.\MotherFactory\PersonMotherFactory.cs
public static class PersonMotherFactory
{
public static object CreatePerson(this MotherFactory mf, ISpecialty specialty = null, IEmployment employment = null)
{
specialty ??= Mock.Of<ISpecialty>();
employment ??= Mock.Of<IEmployment>();
return new(
specialty: specialty,
employment: employment);
}
}
.\UnitTests\HouseEnterTests.cs
public class HouseEnterTests : TestBase
{
[Test]
public void PersonEntersHouse_HousePersonsContainPerson()
{
// Arrange.
var sut = new House();
var person = mf.CreatePerson();
// Act.
sut.Enter(person);
// Assert.
sut.Person.Should().Contain(person);
}
}
Test Data Generator usage example
By default Test Data Generator will use AutoFixture to create test data value.
AutoFixture it's a third-party project. Repository located at: https://github.com/AutoFixture/AutoFixture
Simple code snippet that demonstrates a basic string data initialization, that avoids use of magic strings and abstracts test from unnecessary explicit data specification:
public class PersonTest : TestBase
{
[Test]
public void SetName_NameChanged()
{
// Arrange.
var sut = new Person();
sut.Name = gen.Create<string>();
var expected = gen.Create<string>();
// Act.
sut.Name = expected;
// Assert.
sut.Name.Should().Be(expected);
}
}
To change default Test Data Generator over all tests call
DefaultTestDataGenerator.SetDefaultTestDataGenerator(() => ...);
To change Test Data Generator for specific test class
public class SomeTest : TestBase
{
protected override ITestDataGenerator CreateTestDataGenerator()
{
return ...
}
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- AutoFixture (>= 4.18.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.0 | 546 | 2/24/2024 |