*TestBase* gives you a flying start with - fluent assertions that are simple to extend - sharp error messages - tools to help you test with “heavyweight” dependencies on - AspNetCore.Mvc, AspNet.Mvc 3-5, or WebApi Contexts - HttpClient - Ado.Net - Streams & Logging - Mix & match with your favourite test runners & assertions. # TestBase.HttpClient.Fake ``` //Arrange var httpClient = new FakeHttpClient() .SetupGetUrl("https://host.*/").Returns(request=> "Got:" + request.RequestUri) .SetupGetPath("/uri[Pp]attern/").Returns("stringcontent") .SetupPost(".*").Returns(response) .SetupPost(".*", new byte[]{1,2,3}).Returns(otherResponse) .SetupPost(".*", "a=1&b=2") .Returns( request => "You said : " + request.Content.ReadAsStringAsync().ConfigureFalseGetResult(), HttpStatusCode.Accepted) .Setup(x=>x.RequestUri.PathAndQuery.StartsWith("/this")).Returns(response) .Setup(x=>x.Method ==HttpMethod.Put) .Returns(new HttpResponseMessage(HttpStatusCode.Accepted)); // Act var putResponse = await httpClient.PutAsync("http://localhost/thing", new StringContent("{a=1,b=2}")); var postResponse= await httpClient.PostAsync("http://[::1]/", new StringContent("a=1&b=2")); //Debug httpClient.Invocations .ForEach(async i =>Console.WriteLine("{0} {1}",i.RequestUri, await i.Content.ReadAsStringAsync())); //Assert putResponse.StatusCode.ShouldBe(HttpStatusCode.Accepted); postResponse.ShouldBe(response); // ==> SetupPost(".*").Returns(response) was the first // matched setup. Setups are tried in first-to-last order. httpClient.Verify(x=>x.Method ==HttpMethod.Put, "Expected Put, but no matching invocations."); httpClient.Verify( x=>x.Method ==HttpMethod.Post && x.Content.ReadAsStringAsync().ConfigureFalseGetResult()=="a=1&b=2", "Expected Post a=1&b=2"); httpClient.VerifyAll(); // ==> "Exception : 4 unmatched expectations" ``` ### TestBase Chainable fluent assertions get you to the point concisely. ``` UnitUnderTest.Action() .ShouldNotBeNull() .ShouldEqualByValueExceptFor(new {Id=1, Descr=expected}, ignoreList ) .Payload .ShouldMatchIgnoringCase("I expected this") .Should(someOtherPredicate); .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().ShouldBeOneOf().ShouldNotBeOneOf() numeric.ShouldBeBetween().ShouldEqualWithTolerance()....GreaterThan....LessThan...GreaterOrEqualTo ... ienumerable.ShouldAll().ShouldContain().ShouldNotContain().ShouldBeEmpty().ShouldNotBeEmpty() ... stream.ShouldHaveSameStreamContentAs().ShouldContain() value.ShouldBe().ShouldNotBe().ShouldBeOfType().ShouldBeAssignableTo()... .ShouldAll(predicate), .SingleOrAssertFail()... ``` See also - [TestBase](https://www.nuget.org/packages/TestBase) - [TestBase.AspNetCore.Mvc](https://www.nuget.org/packages/TestBase.AspNetCore.Mvc) - [TestBase-Mvc](https://www.nuget.org/packages/TestBase-Mvc) - [TestBase.AdoNet](https://www.nuget.org/packages/TestBase.AdoNet) - [Serilog.Sinks.ListOfString](https://www.nuget.org/packages/Serilog.Sinks.Listofstring) - [Extensions.Logging.ListOfString](https://www.nuget.org/packages/Extensions.Logging.ListOfString)
Flexible assertion library leveraging the .NET expression tree syntax
Because your tests should be ridiculously easy to read, write and understand... Sahara is an assertion library and auto-mocking framework that lets you write your unit tests in a more natural language syntax and makes it easier to write unit tests for your projects by helping you isolate dependencies away from the classes you want to test.
Contributions to Playwright for .NET 🎭🧪 ⚠️ This package is legacy and is no longer maintained ✔️ PlaywrightContrib.FluentAssertions is a library for writing tests with FluentAssertions against the Playwright API ✔️ It provides a convenient way to write readable and robust browser tests in .NET ✔️ Playwright is built to enable cross-browser web automation that is ever-green, capable, reliable and fast ✔️ FluentAssertions offers a very extensive set of extension methods that allow you to more naturally specify the expected outcome of a TDD or BDD-style unit tests
A very extensive set of extension methods that allow you to more naturally specify the expected outcome of a TDD or BDD-style unit test. This package adds Xamarin support. Supports the unit test frameworks xUnit, NUnit PCL and NUnitLite.
Assent is a simple assertion library for long strings. By default it uses common diff tools to report on and resolve test failures.
This package contains extensions to the Microsoft Visual Studio Team Test unit testing framework. Features include alternatives to ExpectedExceptionAttribute and a fully extensible assertion application programming interface.
Unquote is not just another DSL or API for making unit test assertions. Instead, assertions are written as plain, statically-checked F# quoted expressions and test failure messages are given as step-by-step F# expression evaluations. Unquote integrates configuration-free with all exception-based unit testing frameworks including xUnit.net, NUnit, and Expecto. Unquote may even be used within FSI sessions, enabling the direct migration of ad-hoc FSI tests during interactive development to formal test suites. In addition to its unit testing features, Unquote includes operators for evaluating, decompiling, and incrementally reducing quoted expressions.
.NET extensions and helpers for MSTest.
A really simple C# guard clause/validation library
FluentAssertions extensions for Facility unit tests.
Assert a result to an expected value and provide the diff
Assertions and supporting classes for testing Serilog and its extensions.
A tool for testing (asserting) mapping of properties by comparing one object to another.
Reusable integration test building blocks to write integration tests in a more safe and fun way. The package consists of several functions to help write tests that clean up after themselves, making assertions more reliable by polling for required results, adds some standard building blocks for you to start creating your own disposable fixture, ...
A lightweight .NET library for expressive Guard Clauses.
Method Chaining base UnitTesting Extension Methods and Dynamic Private Accessor for MbUnit. This provides only single .cs file.
LanguageExt extensions for FluentAssertions.
The .NET Memory Profiler API can be used to retrieve memory usage information, perform memory assertions, and collect memory snapshots from within a profiled process. This API is intended to be used for automatic memory testing with the help of .NET Memory Profiler or NmpCore. The SciTech.NmpDataCollector package can be used to easily run a unit test library using NmpCore. For more information, see http://memprofiler.com/, http://memprofiler.com/nmpcore.aspx, and http://memprofiler.com/apiexamples.aspx. Note that this API requires .NET Memory Profiler or NmpCore version 5.7 or later.
This contains some helpful extensions for FluentAssertions like getting the
Package Description
This package contains NUnit 3.x Constraints to be used with XMLUnit.NET's core. XMLUnit provides you with the tools to verify the XML you emit is the one you want to create. It provides helpers to validate against an XML Schema, assert the values of XPath queries or compare XML documents against expected outcomes.
The Should Assertion Library provides a set of extension methods for test assertions for AAA and BDD style tests. It provides assertions only, and as a result it is test runner agnostic. The assertions are a direct fork of the xUnit test assertions. This project was born because test runners Should be independent of the assertions!
A way for performing suite of tests for equality in declarative manner
A fluent assertion .NET Standard library for xUnit version 2.
Includes a string extension method to validate a multi-line string to a multi-line string template. Includes functionality for providing an easy to ready print out of where the multi-line string does not match the template.
Contains Test Helpers mixin infrastructure. Shouldly is used for assertions.
Fluent assertions methods for Playwright
An analyzer to find missing tests for tests written with SmartTests.
This package provides common methods used by all other packages especially the most used data structures of the framework. Additionally it provides implementations for debugging assertions, a weak event model and the logging adapter. For more details how to use MARS, please use the documentation: https://www.mars-group.org/docs/tutorial/intro
NUnit features a fluent assert syntax, parameterized, generic and theory tests and is user-extensible. This package includes the NUnit 3.0 framework assembly for .NET Compact Framework 3.5, which is referenced by your tests. You will need to install the NUnitLiteCF package in order to run the tests. Two separate packages are used because future versions will be supported by additional runners.
Extension methods for asserts for a more readable assert. Ex: 1.ShouldNotBeEqualTo(2)
Contains wrapper for nunit for easy switch between unit test frameworks. This package is aimed to support enterprise level automation where switching between unit test framework is big issue. By wrapping unit test assertion you are able to treat your assertion as interface and seamlessly move from one test framework to another.