Mock کردن HttpClient برای تست نویسی توسط کتابخانه MockHttp
200, OK
https://github.com/richardszalay/mockhttp icon

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'}


Mock کردن HttpClient برای تست نویسی توسط کتابخانه MockHttp
کتاب FakeItEasy Succinctly
301, MovedPermanently
http://www.syncfusion.com/resources/techportal/details/ebooks/fakeiteasy icon

With just some knowledge of IoC, DI, and Unit Testing, begin using FakeItEasy to mock dependencies while unit testing. Author Mike McCarthy will guide readers—from novices to experts—to getting the most out of mocking frameworks with FakeItEasy Succinctly.

کتاب FakeItEasy Succinctly
استفاده از الگوی Repository ؛ بلی یا خیر؟
301, MovedPermanently
http://www.codeproject.com/Articles/875165/To-Repository-Or-NOT icon

این مطلب به صورت اختصاصی مرتبط است به EF و نویسنده اثبات کرده‌است که این روزها قابلیت آزمون پذیری EF به شدت بالا رفته‌است و عملا نیازی به استفاده‌ی از الگوی مخزن، جهت سهولت عملیات mocking در EF نیست.

استفاده از الگوی Repository ؛ بلی یا خیر؟
سری 6 قسمتی TDD
301, MovedPermanently
https://www.simple-talk.com/dotnet/.net-framework/a-tdd-journey-1-trials-and-tribulations/ icon

Part 1: Trials and Tribulations of TDD
Part 2: Naming Tests; Mocking Frameworks; Dependency Injection
Part 3: Mocks vs. Stubs; Test Frameworks; Assertions; ReSharper Accelerators
Part 4: Tests as Documentation; False Positive Results; Component Isolation
Part 5: Tests vs. Code; Refactor Friendliness; Test Parameterization
Part 6: Mini-Factory Pattern; Don’t Care Terms  

سری 6 قسمتی TDD