public async Task VerifyDeleteActionReturnsViewIfEmployeeNotFound() { Guid? employee2Delete = Guid.NewGuid(); var employeeRepository = new Mock<IEmployeeRepository>(); employeeRepository.Setup(x => x.Get(It.IsAny<Guid?>())).Returns(Task.FromResult(default(Employee))); var employeeController = new EmployeeController(employeeRepository.Object); var httpStatusCodeResult = await employeeController.Delete(employee2Delete) as HttpStatusCodeResult; Assert.NotNull(httpStatusCodeResult); Assert.Equal(404, httpStatusCodeResult.StatusCode); }
public async Task VerifyDeleteActionReturnsViewIfEmployeeFound() { var employeeId = Guid.NewGuid(); var employee = new Employee(); employee.Id = employeeId; employee.Name = "Employee"; employee.Designation = "Lead"; employee.JoiningDate = DateTime.UtcNow; employee.Remarks = "Remarks for employee"; var employeeRepository = new Mock<IEmployeeRepository>(); employeeRepository.Setup(x => x.Get(It.IsAny<Guid?>())).Returns(Task.FromResult(employee)); var employeeController = new EmployeeController(employeeRepository.Object); var ViewResult = await employeeController.Delete(employeeId) as ViewResult; Assert.NotNull(ViewResult); Assert.Equal("Delete", ViewResult.ViewName); }
public async Task VerifyDeleteActionReturnsViewIfIdIsNull() { Guid? employee2Delete = null; var employeeRepository = new Mock<IEmployeeRepository>(); var employeeController = new EmployeeController(employeeRepository.Object); var httpStatusCodeResult = await employeeController.Delete(employee2Delete) as HttpStatusCodeResult; Assert.NotNull(httpStatusCodeResult); Assert.Equal(404, httpStatusCodeResult.StatusCode); }