Mastering Inversion of Control (IoC) and Test Driven Design Discipline Concept step-by-step

My Application is going to have 3 type of people entity or maybe more in the future.
For now I have Customers, Agents and Employees. So I created one main Entity which I called Person, and
have these 3 models get inheritance from the Person model.

And to avoid repeating codes on this three entities during implementation, I make use of C#’s Generics,

To illustrate generics in my Unit Testing using Moq. The following codes are for your perusal Kids.! Enjoy!

public class CustomersControllerTest
   Mock<IPersonRepository<Customer>> _repositoryMock;
   CustomersController controller;

   public CustomersControllerTest(Mock<IPersonRepository<Customer>> repositoryMock)
      _repositoryMock = repositoryMock;
   public void SetUp()
      _repositoryMock = new Mock<IPersonRepository<Customer>>();
      controller = new CustomersController(_repositoryMock.Object);            
It's only fair to share...Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn

Leave a Reply

Your email address will not be published. Required fields are marked *