ToolBX.Eloquentest
1.0.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package ToolBX.Eloquentest --version 1.0.0
NuGet\Install-Package ToolBX.Eloquentest -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ToolBX.Eloquentest" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ToolBX.Eloquentest --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ToolBX.Eloquentest, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install ToolBX.Eloquentest as a Cake Addin
#addin nuget:?package=ToolBX.Eloquentest&version=1.0.0
// Install ToolBX.Eloquentest as a Cake Tool
#tool nuget:?package=ToolBX.Eloquentest&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Eloquentest
A simple to use .NET unit testing framework built on top of MSTest and Moq. It also includes built-in support for services that are injected using [AutoInject].
Getting started
Here is the dumbest service you can imagine.
public class DumbestServiceYouCanImagine
{
public string Format(int number)
{
return number == 0 ? "It's zero" : "It's not zero";
}
}
Here is the dumbest unit test for the dumbest service you can imagine.
[TestClass]
public class DumbestServiceYouCanImagineTester : Tester<DumbestServiceYouCanImagine>
{
[TestMethod]
public void WhenNumberIsZero_ReturnItsZero()
{
//Act
var result = Instance.Format(0);
//Assert
Assert.AreEqual("It's zero", result);
}
}
That's all well and good but what if your dumb service had dependencies to other services though?
public interface ISomeOtherService
{
public string UserId { get; }
public IReadOnlyList<int> Roles { get; }
}
public class DumbestServiceYouCanImagine
{
private readonly ISomeOtherService _someOtherService;
public DumbestServiceYouCanImagine(ISomeOtherService someOtherService)
{
_someOtherService = someOtherService;
}
public string DoSomeOtherStuff()
{
return _someOtherService.Roles.Contains(8) ?
$"User {_someOtherService.UserId} is authorized to do dumb stuff." :
$"User {_someOtherService.UserId} is strictly forbidden from doing dumb stuff!";
}
}
[TestClass]
public class DumbestServiceYouCanImagineTester : Tester<DumbestServiceYouCanImagine>
{
[TestMethod]
public void WhenContainsRoleNumberEight_SayThatUserIsAuthorized()
{
//Arrange
var userId = Fixture.Create<string>();
GetMock<ISomeOtherService>().Setup(x => x.UserId).Returns(userId);
GetMock<ISomeOtherService>().Setup(x => x.Roles).Returns(new List<int> { 8 });
//Act
var result = Instance.DoSomeOtherStuff();
//Assert
Assert.AreEqual($"User {userId} is authorized to do dumb stuff.", result);
}
[TestMethod]
public void WhenDoesNotContainRoleNumberEight_SayThatUserIsUnauthorized()
{
//Arrange
var userId = Fixture.Create<string>();
GetMock<ISomeOtherService>().Setup(x => x.UserId).Returns(userId);
GetMock<ISomeOtherService>().Setup(x => x.Roles).Returns(new List<int>());
//Act
var result = Instance.DoSomeOtherStuff();
//Assert
Assert.AreEqual($"User {userId} is strictly forbidden from doing dumb stuff!", result);
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- AutoFixture (>= 4.17.0)
- Microsoft.Extensions.Options (>= 6.0.0)
- Moq (>= 4.16.1)
- MSTest.TestFramework (>= 2.2.7)
- ToolBX.AutoInject (>= 1.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on ToolBX.Eloquentest:
Package | Downloads |
---|---|
ToolBX.Collections.UnitTesting
Tester classes and extensions to help with unit testing ToolBX.Collections. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.2.1 | 2,557 | 1/17/2024 |
2.2.1-beta.1 | 49 | 1/14/2024 |
2.2.0 | 210 | 1/11/2024 |
2.2.0-beta97 | 118 | 1/7/2024 |
2.2.0-beta96 | 58 | 1/4/2024 |
2.2.0-beta94 | 75 | 12/29/2023 |
2.2.0-beta93 | 88 | 12/29/2023 |
2.2.0-beta92 | 72 | 12/29/2023 |
2.2.0-beta91 | 74 | 12/29/2023 |
2.2.0-beta9 | 102 | 12/14/2023 |
2.2.0-beta8 | 65 | 12/13/2023 |
2.2.0-beta7 | 110 | 11/24/2023 |
2.2.0-beta6 | 65 | 11/22/2023 |
2.2.0-beta5 | 62 | 11/22/2023 |
2.2.0-beta4 | 76 | 11/17/2023 |
2.2.0-beta3 | 71 | 11/17/2023 |
2.2.0-beta2 | 55 | 11/17/2023 |
2.2.0-beta11 | 81 | 12/27/2023 |
2.2.0-beta10 | 82 | 12/14/2023 |
2.2.0-beta1 | 68 | 11/17/2023 |
2.2.0-beta.12 | 63 | 12/28/2023 |
2.2.0-alpha.1 | 64 | 12/28/2023 |
2.1.4 | 2,730 | 11/22/2023 |
2.1.4-beta4 | 65 | 11/22/2023 |
2.1.4-beta3 | 71 | 11/17/2023 |
2.1.4-beta2 | 93 | 11/2/2023 |
2.1.4-beta1 | 76 | 10/28/2023 |
2.1.3 | 2,551 | 10/17/2023 |
2.1.3-beta1 | 78 | 10/17/2023 |
2.1.2 | 524 | 10/4/2023 |
2.1.2-beta7 | 113 | 10/3/2023 |
2.1.2-beta6 | 683 | 8/29/2023 |
2.1.2-beta5 | 81 | 8/28/2023 |
2.1.2-beta4 | 81 | 8/25/2023 |
2.1.2-beta3 | 89 | 8/24/2023 |
2.1.2-beta2 | 1,835 | 6/23/2023 |
2.1.2-beta1 | 106 | 6/22/2023 |
2.1.1 | 285 | 6/19/2023 |
2.1.0 | 227 | 6/13/2023 |
2.1.0-beta3 | 126 | 6/13/2023 |
2.1.0-beta2 | 107 | 6/12/2023 |
2.1.0-beta1 | 114 | 6/10/2023 |
2.0.2 | 943 | 4/25/2023 |
2.0.1 | 171 | 4/23/2023 |
2.0.0 | 375 | 11/9/2022 |
2.0.0-beta2 | 127 | 9/28/2022 |
2.0.0-beta1 | 120 | 9/20/2022 |
1.1.2 | 383 | 9/28/2022 |
1.1.1 | 385 | 9/20/2022 |
1.1.1-beta3 | 144 | 8/10/2022 |
1.1.1-beta2 | 120 | 8/10/2022 |
1.1.1-beta1 | 120 | 8/10/2022 |
1.1.0 | 371 | 8/10/2022 |
1.0.7 | 367 | 5/27/2022 |
1.0.6 | 386 | 5/16/2022 |
1.0.5 | 423 | 3/15/2022 |
1.0.5-beta | 137 | 3/15/2022 |
1.0.4 | 436 | 2/5/2022 |
1.0.3 | 399 | 2/4/2022 |
1.0.2 | 393 | 1/14/2022 |
1.0.1 | 234 | 12/22/2021 |
1.0.0 | 266 | 12/15/2021 |