TestBase – Rich, fluent assertions and tools for testing with heavyweight dependencies: AspNetCore, AdoNet, HttpClient, AspNet.Mvc, Streams, Logging NuGet Package

*TestBase* gives you a flying start with
- fluent assertions that are easy to extend
- sharp error messages
- tools to help you test with “heavyweight” dependencies on
- AspNetCore.Mvc, AspNet.Mvc or WebApi Contexts
- HttpClient
- Ado.Net
- Streams & Logging
- Mix & match with your favourite test runners & assertions.

```
UnitUnderTest.Method()
.ShouldNotBeNull()
.ShouldEqualByValueExceptFor(new {Id=1, Descr=expected}, ignoreList )
.Payload
.ShouldMatchIgnoringCase("I expected this")
.Should(someOtherPredicate);
.Items
.ShouldAll(predicate)
.ShouldContain(item)
.ShouldNotContain(predicate)
.Where(predicate)
.SingleOrAssertFail()

item
.ShouldEqualByValue()
.ShouldEqualByValueExceptFor(...)
.ShouldEqualByValueOnMembers()

string
.ShouldMatch(pattern)
.ShouldNotMatch()
.ShouldBeEmpty()
.ShouldNotBeEmpty()
.ShouldNotBeNullOrEmptyOrWhiteSpace()
.ShouldEqualIgnoringCase()
.ShouldContain()
.ShouldBeContainedIn()
.ShouldStartWith()
.ShouldEndWith() ...

numeric
.ShouldBeBetween()
.ShouldEqualWithTolerance()....GreaterThan....LessThan...GreaterOrEqualTo ...

ienumerable
.ShouldAll()
.ShouldContain()
.ShouldNotContain()
.ShouldBeEmpty()
.ShouldNotBeEmpty() ...

stream
.ShouldHaveSameStreamContentAs()
.ShouldContain()

value
.ShouldBe()
.ShouldNotBe()
.ShouldBeOfType()
.ShouldBeAssignableTo() ...

Should.Throw();
Should.ThrowAsync();
Should.NotThrow();

Inconclusive.Because()
Inconclusive.IfPreConditionFails()
Inconclusive.If()
```

Testable Logging is in packages Extensions.Logging.ListOfString and Serilog.Sinks.ListOfString

```
// Extensions.Logging.ListOfString
var log = new List<String>();
ILogger mslogger= new LoggerFactory().AddStringListLogger(log).CreateLogger("Test2");

// Serilog.Sinks.ListOfString
Serilog.Logger slogger= new LoggerConfiguration().WriteTo.StringList(log).CreateLogger();
```.




Got any TestBase – Rich, fluent assertions and tools for testing with heavyweight dependencies: AspNetCore, AdoNet, HttpClient, AspNet.Mvc, Streams, Logging Question?





Info

Version: 5.4.0-preview3
Author(s): Chris F Carroll
Last Update: Sunday, May 3, 2026
.NET Fiddle: Create the first Fiddle
Project Url: https://github.com/chrisfcarroll/TestBase
NuGet Url: https://www.nuget.org/packages/TestBase


Install
Install-Package TestBase
dotnet add package TestBase
paket add TestBase
TestBase Download (Unzip the "nupkg" after downloading)

.NETFramework 4.0 .NETStandard 1.6 4 packages depend on this package.


Tags



STATS

must-have-score

1.6

avg-downloads-per-day

105

days-since-last-release

7