public async Task DeleteAsync_StudentExists_ReturnsNoContent() { Mock <IStudentRepository> studentRepositoryMock = new Mock <IStudentRepository>(); studentRepositoryMock.Setup(m => m.DeleteAsync(It.IsAny <int>())).ReturnsAsync(true); IStudentService studentService = new StudentService(studentRepositoryMock.Object); var studentController = new StudentsController(studentService, this.CreateMapper()); var result = await studentController.DeleteAsync(It.IsAny <int>()); var actual = Assert.IsType <NoContentResult>(result); }
public async Task DeleteAsync_StudentDoesnotExist_ReturnsNotFound() { Mock <IStudentRepository> studentRepositoryMock = new Mock <IStudentRepository>(); studentRepositoryMock.Setup(m => m.DeleteAsync(It.IsAny <int>())).ReturnsAsync(false); IStudentService studentService = new StudentService(studentRepositoryMock.Object); var studentController = new StudentsController(studentService, this.CreateMapper()); var result = await studentController.DeleteAsync(It.IsAny <int>()); var okResult = Assert.IsType <NotFoundObjectResult>(result); var actual = Assert.IsAssignableFrom <string>(okResult.Value); actual.Should().NotBeNullOrWhiteSpace(); actual.Should().Be(string.Format(StudentNotFound, It.IsAny <int>())); }