public void new_should_return_with_user_model() { // Arrange const string actionName = "New"; // Act var sut = new UserControllerBuilder().Build(); var view = sut.New(); // Assert Assert.NotNull(view); Assert.NotNull(view.Model); Assert.IsInstanceOf<BaseController>(sut); Assert.IsAssignableFrom<UserModel>(view.Model); sut.AssertGetAttribute(actionName); sut.AssertAllowAnonymousAttribute(actionName); }
public async void password_change_should_return_with_password_change_model() { // Arrange const string actionName = "PasswordChange"; const string email = "*****@*****.**"; const string token = "token"; var userService = new Mock<IUserService>(); userService.Setup(x => x.IsPasswordResetRequestValid(email, token)) .Returns(() => Task.FromResult(true)); // Act var sut = new UserControllerBuilder().WithUserService(userService.Object) .Build(); var task = await sut.PasswordChange(email, token); var view = task as ViewResult; // Assert Assert.NotNull(view); Assert.NotNull(view.Model); Assert.IsInstanceOf<BaseController>(sut); Assert.IsAssignableFrom<PasswordChangeModel>(view.Model); sut.AssertGetAttribute(actionName, new[] { typeof(string), typeof(string) }); sut.AssertAllowAnonymousAttribute(actionName, new[] { typeof(string), typeof(string) }); }
public void logout_should_return_view() { // Arrange const string actionName = "Logout"; var formsAuthenticationService = new Mock<IFormsAuthenticationService>(); formsAuthenticationService.Setup(x => x.SignOut()); // Act var sut = new UserControllerBuilder().WithFormsAuthenticationService(formsAuthenticationService.Object) .Build(); var view = sut.Logout(); // Assert Assert.NotNull(view); Assert.AreEqual(view.Url, "/"); Assert.IsInstanceOf<BaseController>(sut); Assert.IsAssignableFrom<RedirectResult>(view); sut.AssertGetAttribute(actionName); }