Exemple #1
0
        public async Task <IActionResult> Delete([FromRoute] Guid goalId)
        {
            var goalDeleted = await GoalService.DeleteAsync(goalId);

            return(goalDeleted
                ? NoContent()
                : StatusCode((int)HttpStatusCode.NotModified));
        }
Exemple #2
0
        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>());
        }
Exemple #3
0
        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));
        }
Exemple #4
0
        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));
        }