Deprecated, use Flurl.Http https://www.nuget.org/packages/Flurl.Http/
An InProcess HTTP server which can be mocked and asserted against to allow for full stack HTTP testing
This library extends the core functionality of FluentAssertions by adding assertions on the HttpResponseMessage class. Fluent assertions quickstarts and tutorials - https://fluentassertions.com
Enhancements and utility classes for primitive types and some commonly used types in the mscorlib and System.Core libraries. Extension methods are available for string, DateTime, enum, StringBuilder, SecureString, RegEx, event handlers, random, array, Enumberable, IList, collections, stream and various derivatives. Utility classes include the SortUtility class for topological sorting, the Assert class for argument validation, and FastConvert class for performance optimized serialization between various primitive types and string. Also include various utility classes for DateTime, enum, HTTP, mathematics, random and string. A ConcurrentSortedList generic collection type is implemented in this library, which expands on the SortedList type to support multi-threading.
**SystemTestingTools** (for .net core 3.1+) extends your test capabilities, providing ways to create / return stubs, allowing you to run more comprehensive / deterministic / reliable tests in your local dev machine / build tool and in non-prod environments. * supporting interception of Http (HttpClient or WCF) calls: * before they are sent, returning stubs (ideal for automated testing) * after they are sent, where you can save the request and response (recording), log appropriately or replace bad responses by stubs (ideal for dev/test environments that are flaky or not ready) * asserting outgoing calls (ie: making sure out downstream calls have SessionIds) * intercept logs and run asserts on them
This is a FluentAssertions extension over the HttpResponseMessage object. It provides assertions specific to HTTP responses and outputs rich erros messages when the tests fail, so less time with debugging is spent.
Components for Data Protection, Secure Storage, Secure Transfer, and Advanced Electronic Signatures, including PAdES for PDF, XAdES for XML, and full support for Hardware Security Modules (HSM).
Adds extensions to HttpClient for sending http requests and asserting against http responses for testing.
*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.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()... ``` TestBase.HttpClient.Fake ``` new FakeHttpClient() .Setup(x=>x.RequestUri.PathAndQuery.StartsWith("/this")) .Returns(response) .Setup(x=>x.Method==HttpMethod.Put) .Returns(new HttpResponseMessage(HttpStatusCode.Accepted)); ``` TestBase.AdoNet ------------------ `FakeDbConnection` ``` - db.SetupForQuery(…) - db.SetupForExecuteNonQuery(…) - db.ShouldHaveUpdated("tableName", …) - db.ShouldHaveSelected("tableName", …) - db.ShouldHaveDeleted("tableName", …) - db.Verify( x=>x.CommandText.Matches("Insert [case] .*") && x.Parameters["id"].Value==1 ) - db .ShouldHaveInvoked(cmd => predicate(cmd)) .ShouldHaveParameter("name", value) ``` `RecordingDbConnection` TestBase.Mvc.AspNetCore & TestBase.Mvc for Mvc 4 & Mvc 5 -------------------------------------------------------- ``` ControllerUnderTest.WithControllerContext() .Action() .ShouldbeViewResult() .ShouldHaveModel<TModel>() .ShouldEqualByValue(expected) ControllerUnderTest.Action() .ShouldBeRedirectToRouteResult() .ShouldHaveRouteValue("expectedKey", [Optional] "expectedValue"); ShouldHaveViewDataContaining(), ShouldBeJsonResult() etc. ``` - Test AspNetCore controllers with zero setup using `controllerUnderTest.WithControllerContext(actionUnderTest)` - Test more complex AspNetCore controller/application dependencies using `HostedMvcTestFixtureBase` and specify your MVCApplications `Startup` class. ``` [TestCase("/dummy")] public async Task Put_Should_ReturnA(string url) { var httpClient=GivenClientForRunningServer<Startup>(); GivenRequestHeaders(httpClient, "CustomHeader", "HeaderValue1"); var result = await httpClient.PutAsync(url, json); result.ShouldBe_202Accepted(); } ``` For Mvc4 and Mvc 5, fake your http request & context, and use the `RegisterRoutes` method of your actual application to set up `Controller.Url` ``` ControllerUnderTest .WithHttpContextAndRoutes( RouteConfig.RegisterRoutes, "/incomingurl" ); ApiControllerUnderTest.WithWebApiHttpContext<T>( httpMethod, requestUri, routeTemplate) ``` Testable Logging ``` // 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(); ```
*TestBase* gets you off to a flying start when unit testing projects with dependencies. TestBase-Mvc adds a rich extensible set of fluent assertions for verifying Mvc ActionResults and for easy setup of ControllerContext and HttpContext for both Mvc and WebApi TestBase.Shoulds ------------------- Chainable fluent assertions get you to the point concisely ControllerUnderTest.Action() .ShouldbeViewResult() .ShouldHaveModel<TModel>() .ShouldEqualByValue(expected) ControllerUnderTest.Action() .ShouldBeRedirectToRouteResult() .ShouldHaveRouteValue("expectedKey", [Optional] "expectedValue"); ShouldHaveViewDataContaining(), ShouldBeJsonResult() etc. TestBase ---------- Controller extensions to fake the http request & context. By injecting the RegisterRoutes method of your MvcApplication, you can use and test Controller.Url with your application's configured routes. ControllerUnderTest .WithHttpContextAndRoutes( [Optional] Action<RouteCollection> mvcApplicationRoutesRegistration, [optional] string requestUrl, [Optional] string query = "", [Optional] string appVirtualPath = "/", [Optional] HttpApplication applicationInstance) ApiControllerUnderTest.WithWebApiHttpContext<T>( HttpMethod httpMethod, [Optional] string requestUri, [Optional] string routeTemplate)
Fluent API for asserting HTTP message exchanges (currently under active development).
**This package is a fork from https://github.com/djmnz/RestFluencing/** Framework to help testing Restful APIs in a fluent style that are easy to write and understand. Allows you to write your Api Requests and Asserting the response in a fluent manner. Compatible with NUnit, MSTest, XUnit and any test runner.
HTTP Assert (http-assert) binding library for Bridge.NET projects.
A fluent, portable, testable HTTP client library.
Reusable HTTP server 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, ...
This is a FluentAssertions extension over the HttpResponseMessage object. It provides assertions specific to HTTP responses and outputs rich erros messages when the tests fail, so less time with debugging is spent. This version depends on the commercial version of the FluentAssertions library (>= 8.0.0).