Found 13 packages
Abbotware Interop Library for NUnit - Contains helper methods, extension methods, and plugins
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.
Define an expected exception with optional expectations.
Provides a set of Exception oriented extension methods methods extending from Xunit.
Contains classes to help with testing when entity and a SQL Server would be involved in production: * TestFixtureWithTempDb provides bootstrapping for tests which would use a temporary database (TempDBLocalDb) * EntityPersistenceTestFixtureBase provides helpers for the common test of persisting and recalling entities to test that mappings (automatic or manual) work as expected * DbContextExtensions adds SaveChangesWithErrorReporting(), an extension method for DbContext derivatives to provide more information within tests as to why a test is failing (such information is usually buried within the exception maze that Entity provides)
This library provides guard clauses that could be used to guard against not expected values. It provides conditions for objects, strings, numerics, datatime and enumerables. It is possible to configure which exception should be thrown.
MSTest TestFramework Extensions such as BenchmarkTest or ExpectedExceptionWithMessage attributes or an embedded manifest resource helper class.
Some helper methods to write "better" / "easier to read" unit tests. One example is ExpectedExceptionMessageAttribute - a replacement fo the ExpectedExceptionAttribute that also validates the exception message.
LiteX.Guard is a simple guard clause argument validation library, that helps you with validation of your arguments. A simple package with guard clause helper methods. This library provides guard clauses that could be used to guard against not expected values. It provides conditions for objects, strings, numerics, datatime and enumerables. It is possible to configure which exception should be thrown. Argument validation made simple and unified. It ensures arguments conforms to simple validation rules and provides an uniformed exception throwing strategy if arguments are invalid.
Manage your DbContexts the right way. The persistence or infrastructure layer uses the DbContext (e.g. from a repository). Controlling its scope and transaction lifetime, however, is ideally the reponsibility of the orchestrating layer (e.g. from an application service). This package adds that ability to Entity Framework Core 5.0.0 and up. https://github.com/TheArchitectDev/Architect.EntityFramework.DbContextManagement Release notes: 2.0.1: - Enhancement: Upgraded package versions. 2.0.0: - BREAKING: Now using AmbientContexts 2.0.0. - Semi-breaking: Failure on commit (extremely rare) now throws IOException instead of Exception. - Added static DbContextScope<TDbContext>.HasDbContext, to match the feature set of IDbContextAccessor. - Retries now ensure that the connection is closed before retrying, to avoid the risk of leaking session state. (As with EF's DbContext disposal in general, this relies on the database provider's connection reset.) - Scoped execution now protects against dangerous "failure on commit" retries even on manual commits (rather than just on IExecutionScope's implicit commit). - Worked around an EF bug where the DbContext would obscure the exception caused by a broken model behind an ObjectDisposedException, even though DbContext._disposed=false. - Scoped execution: Fixed a bug where the exception caused by a broken model would be obscured behind a wrongful IncompatibleVersionException. - MockDbContextProvider: Fixed a bug where nested scopes would not work as expected. - MockDbContextProvider: Fixed a bug where soft attempts to roll back a transaction when there was none could cause an unintended TransactionAbortedException. 1.0.1: - Now using AmbientContexts 1.1.1, which fixes extremely rare bugs and improves performance.
NSubstitute extensions for NExpect so you can: ``` Expect(foo).(Not).To.Have.Received().Method(..); ```
generic decorators providing: * management of IDisposable instances including transferance of ownership * storage class for an expected or optional result with either an enum or exception to explain why it's not present
*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)