Пример #1
0
        public ActionResult DeleteGoal(string teamName, string goalName)
        {
            var serviceMessage = _goalService.DeleteGoal(teamName, goalName);

            if (serviceMessage == "success")
            {
                return(Ok());
            }

            return(NotFound(serviceMessage));
        }
Пример #2
0
        public void ShouldThrowANullReferenceExceptionWhenGoalDoesNotExistWithUserIdWhenDeleting()
        {
            //Arrange
            int  expectedId     = 1;
            int  expectedUserId = 1;
            Goal expectedGoal   = new Goal(expectedId, "Testing Goal", "Testing Goal", 100, GoalStatus.Open, false);

            //Pretend the goal does not exist
            mockGoalRepository.Setup(gr => gr.GetGoalForUser(It.Is <int>(val => val == expectedId), It.Is <int>(val => val == expectedUserId))).Returns(null as Goal);
            IGoalService goalService = new GoalService(mockGoalRepository.Object);

            //Act
            Action failAction = () => goalService.DeleteGoal(expectedUserId, expectedId);

            //Assert
            failAction.Should().Throw <NullReferenceException>();
        }
Пример #3
0
        public void ShouldDeleteGoalForUserBasedOnGoalIdAndUserId()
        {
            //Arrange
            int  expectedId     = 1;
            int  expectedUserId = 1;
            Goal expectedGoal   = new Goal(expectedId, "Testing Goal", "Testing Goal", 100, GoalStatus.Open, false);

            //Pretend the goal exists
            mockGoalRepository.Setup(gr => gr.GetGoalForUser(It.Is <int>(val => val == expectedId), It.Is <int>(val => val == expectedUserId))).Returns(expectedGoal);

            //Pretend the delete goals operation goes smoothly
            mockGoalRepository.Setup(gr => gr.Delete(It.Is <int>(val => val == expectedId))).Returns(expectedGoal);

            IGoalService goalService = new GoalService(mockGoalRepository.Object);

            //Act
            bool goalRemoved = goalService.DeleteGoal(expectedUserId, expectedId);

            //Assert
            goalRemoved.Should().Be(true);
        }