Testing number of times method being called with Moq (Complex)
In the last post we discussed how to test the number of times a methods being called using Moq framework. In this post we will discuss little more complex scenario to test the number of times a method being called with the help of a collection type example.
Here is the complete video discussion
Here is the complete code from above video
List employees = new List()
EmpId = 1,
Name = "Karthik",
Salary = 4000,
DurationWorked = 24,
Grade = 1,
Email = "firstname.lastname@example.org"
EmpId = 2,
Name = "Prashanth",
Salary = 7000,
DurationWorked = 30,
Grade = 2,
Email = "email@example.com"
var moqPersonalDetail = new Mock();
var empDetails = new EmployeesDetails(moqPersonalDetail.Object);
moqPersonalDetail.Verify(x => x.GetEmployeeDetails(It.IsAny()),Times.Exactly(employees.Count));
Thanks for reading the post and watching the video!!!
Please leave your comments and let me know if there is anything I should update in this post.