public void Index_returns_default_view() { //act var result = _controller.Index(1); //assert Assert.IsType <ViewResult>(result); Assert.Empty(result.ViewName); }
public void TestIndex_ShouldCallServiceGetUsers() { // Arrange var mockedAuthenticationProvider = new Mock <IAuthenticationProvider>(); var mockedUserService = new Mock <IUserService>(); var controller = new UserAdministrationController(mockedUserService.Object, mockedAuthenticationProvider.Object); // Act controller.Index(); // Assert mockedUserService.Verify(s => s.GetUsers(), Times.Once); }
public void TestIndex_ShouldCallAuthProviderIsInRoleTimesUsersCount() { // Arrange var users = new List <User> { new User(), new User() }; var mockedAuthenticationProvider = new Mock <IAuthenticationProvider>(); var mockedUserService = new Mock <IUserService>(); mockedUserService.Setup(s => s.GetUsers()).Returns(users); var controller = new UserAdministrationController(mockedUserService.Object, mockedAuthenticationProvider.Object); // Act controller.Index(); // Assert mockedAuthenticationProvider.Verify(p => p.IsInRole(It.IsAny <string>(), Common.Constants.AdministratorRoleName), Times.Exactly(users.Count)); }