TestBase 3.0.2
dotnet add package TestBase --version 3.0.2
NuGet\Install-Package TestBase -Version 3.0.2
<PackageReference Include="TestBase" Version="3.0.2" />
paket add TestBase --version 3.0.2
#r "nuget: TestBase, 3.0.2"
// Install TestBase as a Cake Addin #addin nuget:?package=TestBase&version=3.0.2 // Install TestBase as a Cake Tool #tool nuget:?package=TestBase&version=3.0.2
*TestBase* gets you off to a flying start when unit testing projects with dependencies.
It offers a rich extensible set of fluent assertions and a set of verifiable Fake Ado.Net components, with easy setup and verification.
TestBase.Shoulds
------------------
Chainable fluent assertions drill down to the point concisely.
UnitUnderTest.Action().ShouldNotBeNullOrEmpty().ShouldContain(x=>x.ExpectedField == expected);
* Lots of Shoulds: ShouldBe(),ShouldSatisfy(),ShouldHave(),ShouldBeTrue(),ShouldBeGreaterThan(),ShouldBeLessThan(),ShouldBeGreaterThanOrEqual(),ShouldBeAssignableTo(),ShouldBeBetween(),ShouldBeNullOrEmpty(),...
* Enumerable Assertions: ShouldBeEmpty(),ShouldContain(),ShouldContainEachItemOf(),ShouldBeIn(),ShouldHave(),ShouldAll(),...
* Lots of Nots: ShouldNotBe(),ShouldNotBeNullOrEmpty(),ShouldNotContain(),...
* String & Regex Assertions:ShouldContain(),ShouldEqualIgnoringCase(),ShouldMatch(),ShouldNotBeNullOrEmptyOrWhitespace(),...
* StreamAssertions:ShouldContain(stream),ShouldContain(byte[]),ShouldEqualByValue(stream)
* ShouldEqualByValue() compares all kinds of objects and collections field-by-field, by value, basis
new{f1=1,f2="2"}ShouldEqualByValue(new{f1=1,f2="2"});
new[]{1,2}.ShouldEqualByValue(new List<int>{1,2});
TestBase.FakeDb
------------------
Works with Ado.Net and technologies on top of it, including Dapper.
* fakeDbConnection.SetupForQuery(fakeData, new[] {"FieldName1", FieldName2"})
* fakeDbConnection.SetupForExecuteNonQuery(rowsAffected)
* fakeDbConnection.Verify(x=>x.CommandText.Matches("Insert MyTable") && x.Parameters["id"].Value==1)
TestBase.TestBase<T> AutoMocksAndFakes
--------------------------------
is in development and currently works non-recursively. It auto-constructs the UnitUnderTest.
It identifies constructor dependencies by name and type, looking in the following places:
1) Fields in the TestFixture class
2) Entries in the Mocks[] or Fake[] dictionaries
3) Finally it creates a Mock (if it's a mockable type) or a default instance (if its sealed, or value type) for anything that's missing
See also: TestBase-Mvc for Asp.Net MVC assertions such as ControllerUnderTest.Action().ShouldBeViewResult().ShouldHaveModelOfType<T>().Field1.ShouldEqual(expected);
ChangeLog
---------
3.0.2.0 Added ShouldBeLessThan,ShouldBeIn
2.0.5.0 Adds some intellisense and FakeDbConnection.Verify(..., message,args) overload
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net40 is compatible. net403 was computed. net45 was computed. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version 1. Unpolished but in use for over a year