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!
_repositoryMock = new
controller = new
Early Today I struggled on implementing Dependency Injection using Unity on a new Asp.net MVC 5 setup. I struggle so much that I move on to unit testing instead just to make some progress today using Moq.
So Unit Testing my Project right now is using only the Repository Pattern. I’ll be back on Dependency Injection Containers Maybe next week. I’ll use this Repository Pattern setup to finish my 2 projects this week.
Here are some code highlights
Instantiating your controller
_customerRepository = new
Moq Unit Testing
var customers = new
var result =
var model =
Repository Interface for Customers Implementation
public interface ICustomerRepository : IDisposable
Customer GetByID(int id);
void Delete(int id);
void SaveOrUpdate(Customer customer);
This will now be my base code to implement by Billing and Payroll Applications.
If this piece of code in Asp.Net MVC 5 on .Net 4.6 is Not working
Just code it like this.
ApplicationUser u =
var roles =
s = new
var i in
var r =
It will save you time.
Alright Kids! You’re Welcome!