public void Index() { //Arrange MockBenutzerViewModelService = new Mock <IBenutzerViewModelService>().Object; var controller = new HomeController(MockBenutzerViewModelService); FakeHttpContext.SetFakeContext(controller, true); //Act ViewResult result = controller.Index() as ViewResult; //Assert Assert.IsNotNull(result); }
public void PasswordChange_HTTPGet_FalseVerifyCode_Test() { //Arrange var mockBenutzerService = new Mock <IBenutzerService>(); mockBenutzerService.Setup(x => x.VerifyPasswordChange(It.IsAny <string>(), It.IsAny <string>())).Returns(false); var newMockBenutzerService = mockBenutzerService.Object; var accountController = new AccountController(MockLoginService, newMockBenutzerService, MockBenutzerViewModelService); accountController.ControllerContext = new ControllerContext(); FakeHttpContext.SetFakeContext(accountController, true); //Act ActionResult result = accountController.PasswordChange("TestID", "TESTVerify"); //Assert Assert.IsNotNull(result); }
public void PasswordChange_HTTPPost_VerifyFalse_ModelStateOk_Test() { //Arrange var mockBenutzerService = new Mock <IBenutzerService>(); mockBenutzerService.Setup(x => x.VerifyPasswordChange(It.IsAny <string>(), It.IsAny <string>())).Returns(false); mockBenutzerService.Setup(x => x.EditBenutzerPassword(It.IsAny <Benutzer>())); var newMockBenutzerService = mockBenutzerService.Object; var accountController = new AccountController(MockLoginService, newMockBenutzerService, MockBenutzerViewModelService); accountController.ControllerContext = new ControllerContext(); FakeHttpContext.SetFakeContext(accountController, true); //Act ActionResult result = accountController.PasswordChange(Fixture.Build <ForgottenPasswordCreateNewPasswordViewModel>().Create(), "TestId", "TestVerify"); string routeAction = ((RedirectToRouteResult)result).RouteValues["Action"].ToString(); //Assert Assert.IsNotNull(result); Assert.AreEqual("~/Views/Shared/Error.cshtml", routeAction); }