A curated collection of publicly available resources on how software companies around the world test their software systems and build their quality culture.
MockHttp is a testing layer for Microsoft's HttpClient library. It allows stubbed responses to be configured for matched HTTP requests and can be used to test your application's service layer.
var mockHttp = new MockHttpMessageHandler(); // Setup a respond for the user api (including a wildcard in the URL) mockHttp.When("http://localhost/api/user/*") .Respond("application/json", "{'name' : 'Test McGee'}"); // Respond with JSON // Inject the handler or client into your application code var client = mockHttp.ToHttpClient(); var response = await client.GetAsync("http://localhost/api/user/1234"); // or without async: var response = client.GetAsync("http://localhost/api/user/1234").Result; var json = await response.Content.ReadAsStringAsync(); // No network connection required Console.Write(json); // {'name' : 'Test McGee'}
توسط این کتابخانه میتوانید دیتابیسهای MongoDb را بدون نیاز به نصب آنها، به صورت یکبار مصرف ایجاد کنید. یعنی یک دیتابیس موقت (در پوشه Temp سیستم عامل) برای شما میسازد و در آخر وقتی کار شما با آن تمام شد، آن را حذف میکند. در نتیجه برای Integration Testing بسیار مناسب و کاربردی هست.
طرز کار با آن خیلی سادهاست؛ فقط کافی است بستهی NuGet آن را نصب کنید:
Install-Package Mongo2Go
و به صورت زیر از آن استفاده کنید:
using (var runner = MongoDbRunner.Start()) { var client = new MongoClient(runner.ConnectionString); var database = client.GetDatabase("IntegrationTest"); var collection = database.GetCollection<TestDocument>("TestCollection"); //Just use it! }
MyTested.AspNetCore.Mvc is a strongly-typed unit testing library providing an easy fluent interface to test the ASP.NET Core MVC framework. It is testing framework agnostic so that you can combine it with a test runner of your choice (e.g. xUnit, NUnit, etc.).