public void Can_Edit_Goal()
        {
            //Prepare
            var       goalRepository = new GoalRepository();
            const int existedGoalId  = 1;
            var       oldGoal        = new Goal
            {
                Id       = existedGoalId,
                Name     = "OldName",
                Priority = PriorityType.Low
            };
            var expectedGoal = new Goal
            {
                Id       = existedGoalId,
                Name     = "New Name",
                Priority = PriorityType.High
            };

            goalRepository.Add(oldGoal);
            //Pre-Validate
            var existedGoal = goalRepository.Goals.First(e => e.Id == existedGoalId);

            Assert.Equal(oldGoal.Name, existedGoal.Name);
            Assert.Equal(oldGoal.Priority, existedGoal.Priority);

            //Perform
            var result = goalRepository.Edit(expectedGoal);

            //Post-Validate
            Assert.Equal(expectedGoal.Id, result.Id);
            Assert.Equal(expectedGoal.Name, result.Name);
            Assert.Equal(expectedGoal.Priority, result.Priority);
        }
Пример #2
0
        /// <summary>
        /// Edits a goal.
        /// </summary>
        /// <param name="goal"></param>
        /// <returns></returns>
        public bool Edit(Goal goal)
        {
            // Wanneer de goal succesvol is afgerond wordt de progress parameter automatisch 100%.
            if (goal.Status == GoalStatus.Finished && goal.Progress != 100)
            {
                goal.Progress = 100;
            }

            // Checkt de goal voor ongewenste of inconsistente gegevens.
            if (!goal.CheckForInconsistenties())
            {
                return(false);
            }

            bool response = repo.Edit(goal);

            return(response);
        }