public void Call_DomainService_AddDomain_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); var userId = "userId"; loggedInUser.Setup(l => l.GetUserId()).Returns(userId); AddDomainViewModel addDomainViewModel = new AddDomainViewModel() { Name = "name", Description = "description" }; // Act sellerController.AddDomain(addDomainViewModel); // Assert domainService.Verify( d => d.AddDomain(addDomainViewModel.Name, addDomainViewModel.Description, userId), Times.Once()); }
public void Set_TempData_SuccessMessage() { // 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); var userId = "userId"; loggedInUser.Setup(l => l.GetUserId()).Returns(userId); AddDomainViewModel addDomainViewModel = new AddDomainViewModel() { Name = "name", Description = "description" }; // Act sellerController.AddDomain(addDomainViewModel); // Assert sellerController.ShouldHaveTempDataProperty("Success", "Added successfully!"); }