Info
Version: | 4.3.0 |
Author(s): | Chris F Carroll |
Last Update: | Monday, December 9, 2024 |
.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)
Dependencies
.NETFramework 4.0
- ExpressionToCodeLib(>= 2.7.0)
- Newtonsoft.Json(>= 7.0.1)
- ExpressionToCodeLib(>= 2.7.0)
- FastExpressionCompiler(>= 1.7.1)
- NETStandard.Library(>= 1.6.1)
- Newtonsoft.Json(>= 9.0.1)
- System.ComponentModel.Annotations(>= 4.4.1)
Tags
- 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.Action()
.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()
.ShouldEqualByValue().ShouldEqualByValueExceptFor(...).ShouldEqualByValueOnMembers()
work with all kinds of object and collections, and report what differed.
string.ShouldMatch(pattern).ShouldNotMatch().ShouldBeEmpty().ShouldNotBeEmpty()
.ShouldNotBeNullOrEmptyOrWhiteSpace().ShouldEqualIgnoringCase()
.ShouldContain().ShouldStartWith().ShouldEndWith().ShouldBeContainedIn(), ...
numeric.ShouldBeBetween().ShouldEqualWithTolerance()....GreaterThan....LessThan...GreaterOrEqualTo ...
ienumerable.ShouldAll().ShouldContain().ShouldNotContain().ShouldBeEmpty().ShouldNotBeEmpty() ...
stream.ShouldHaveSameStreamContentAs().ShouldContain()
value.ShouldBe().ShouldNotBe().ShouldBeOfType().ShouldBeAssignableTo()...
```
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();
```.