public async Task <IActionResult> Delete([FromRoute] Guid goalId) { var goalDeleted = await GoalService.DeleteAsync(goalId); return(goalDeleted ? NoContent() : StatusCode((int)HttpStatusCode.NotModified)); }
public async Task DeleteAsync_WhenGoalIdGuidEmpty_ShouldReturnFalse( GoalService sut) { // Arrange var goalId = Guid.Empty; // Act var result = await sut.DeleteAsync(goalId); // Asserts result.Should().BeFalse(); await sut.GoalRepository.DidNotReceive().DeleteAsync(Arg.Any <Guid>()); }
public async Task DeleteAsync_WhenDeleteFails_ShouldReturnCorrectly( Guid goalId, GoalService sut) { // Arrange sut.GoalRepository.DeleteAsync(Arg.Is(goalId)).Returns(false); // Act var result = await sut.DeleteAsync(goalId); // Asserts result.Should().BeFalse(); await sut.GoalRepository.Received(1).DeleteAsync(Arg.Is(goalId)); }
public async Task DeleteAsync_ShouldCallMethodCorrectly( Guid goalId, GoalService sut) { // Arrange sut.GoalRepository.DeleteAsync(Arg.Is(goalId)).Returns(true); // Act var result = await sut.DeleteAsync(goalId); // Asserts result.Should().BeTrue(); await sut.GoalRepository.Received(1).DeleteAsync(Arg.Is(goalId)); }