public void Call_GetUserByStringId_From_UserService_Once() { // Arrange var domainService = new Mock <IDomainService>(); var userService = new Mock <IUserService>(); var loggedInUser = new Mock <ILoggedInUser>(); var sellerController = new SellerController(userService.Object, domainService.Object, loggedInUser.Object); string userId = "userId"; var createdOn = new DateTime(17, 1, 1); var user = new User() { Id = userId, FirstName = "firstname", LastName = "lastname" }; var rejectedDomains = new List <Domain>() { new Domain() { StatusId = 2 } }; var pendingDomains = new List <Domain>() { new Domain() { StatusId = 1 } }; var publishedDomains = new List <Domain>() { new Domain() { StatusId = 4 } }; var soldDomains = new List <Domain>() { new Domain() { StatusId = 5 } }; user.SellerDomains.Add(rejectedDomains[0]); user.SellerDomains.Add(pendingDomains[0]); user.SellerDomains.Add(publishedDomains[0]); user.SellerDomains.Add(soldDomains[0]); user.CreatedOn = createdOn; user.Balance = 10000; loggedInUser.Setup(l => l.GetUserId()).Returns(userId); userService.Setup(u => u.GetUserByStringId(userId)).Returns(user); // Act sellerController.Index(); // Assert userService.Verify(u => u.GetUserByStringId(userId), Times.Once()); }