public async Task Delete_ReturnsARedirectToAction_Index(int?id) { var result = await sut.DeleteConfirmed(id.Value); Assert.IsType <RedirectToActionResult>(result); var actionName = ((RedirectToActionResult)result).ActionName; Assert.Equal("Index", actionName); }
public async Task UpdateDelete_ReturnsAViewResult() { // Arrange var model = new Student() { Id = 1, Faculty = "AMI", Group = new Group { Name = "AMI31" }, GroupId = 1, UserId = "1" }; var mockLogic = new Mock <IStudentsLogic>(); int studentId = 1; mockLogic.Setup(repo => repo.GetStudent(studentId)).Returns(Task.FromResult(model)); var controller = new StudentsController(mockLogic.Object); // Act IActionResult actionResult = await controller.DeleteConfirmed(studentId); // Assert var viewResult = Assert.IsType <RedirectToActionResult>(actionResult); mockLogic.Verify(repo => repo.DeleteStudent(model), Times.Once); }
public void DeletePostStudentValid() { //act var actual = (RedirectToRouteResult)controller.DeleteConfirmed(1); //assert Assert.AreEqual("Index", actual.RouteValues["action"]); }
public void TestDeleteConfirmation() { Mock <IStudentService> studentService = new Mock <IStudentService>(); var controller = new StudentsController(studentService.Object); var result = (RedirectToRouteResult)controller.DeleteConfirmed(2); Assert.AreEqual("Index", result.RouteValues["action"]); }
public void Delete_Post() { _studentService.Setup(s => s.Delete(1)).Returns(1); var vr = _controller.DeleteConfirmed(1) as RedirectToRouteResult; Assert.Equal("Index", vr.RouteValues["action"]); _studentService.Verify(); }
public void Students_Controller_Test_On_Delete_Confirmed_With_Existent_Id() { //Arrange Guid id = new Guid("f616cc8c-2223-4145-b7d0-232a1f6f0795"); string firstName = "TestF"; string lastName = "TestL"; string userName = "******"; string password = "******"; string emailAdress = "TestE"; Student expectedStudent = new Student(firstName, lastName, userName, password, emailAdress); expectedStudent.Id = id; var repo = Substitute.For <IRepository>(); var sut = new StudentsController(repo); repo.GetById <Student>(id).Returns(expectedStudent); //Act var actual = sut.DeleteConfirmed(id).Result; //Assert Assert.IsInstanceOfType(actual, typeof(RedirectToActionResult)); }