Exemplo n.º 1
0
        public void Goal_With_Four_PercentTasks_At_Varying_Percents_And_Weightings_Returns_Correct_PercentComplete()
        {
            var goal = new Goal();

            var task1 = new PercentGoalTask {
                Id = 1, CreateDate = DateTime.Now, Title = "Task 1", Weighting = 25
            };
            var task2 = new PercentGoalTask {
                Id = 1, CreateDate = DateTime.Now, Title = "Task 2", Weighting = 40
            };
            var task3 = new PercentGoalTask {
                Id = 1, CreateDate = DateTime.Now, Title = "Task 3", Weighting = 60
            };
            var task4 = new PercentGoalTask {
                Id = 1, CreateDate = DateTime.Now, Title = "Task 4", Weighting = 75
            };

            goal.AddTask(task1);
            goal.AddTask(task2);
            goal.AddTask(task3);
            goal.AddTask(task4);

            task1.AddSession(new PercentSessionResult(DateTime.Now, DateTime.Now.AddMinutes(10), 100));
            task2.AddSession(new PercentSessionResult(DateTime.Now, DateTime.Now.AddMinutes(10), 60));
            task3.AddSession(new PercentSessionResult(DateTime.Now, DateTime.Now.AddMinutes(10), 40));
            task4.AddSession(new PercentSessionResult(DateTime.Now, DateTime.Now.AddMinutes(10), 25));

            Assert.That(goal.PercentComplete, Is.InRange(45.87, 45.9));
            Assert.That(goal.IsConsideredComplete, Is.False);
        }
Exemplo n.º 2
0
        public void Goal_With_Two_Unequally_Weighted_Tasks_Returns_Correct_Percent_Complete()
        {
            Goal goal = new Goal();

            var task1 = new MetronomeGoalTask
            {
                StartSpeed  = 100,
                TargetSpeed = 120,
                Title       = "Metronome Task",
                Weighting   = 50
            };

            var task2 = new DurationGoalTask
            {
                Weighting     = 100,
                TargetMinutes = 60,
                Title         = "Duration Task"
            };

            var task3 = new PercentGoalTask();

            task1.Title     = "Percent Task";
            task3.Weighting = 50;

            goal.AddTask(task1);
            goal.AddTask(task2);
            goal.AddTask(task3);

            // all exactly half done...
            task1.AddSession(new MetronomeSessionResult(DateTime.Parse("2018/06/22 18:33:20"), DateTime.Parse("2018/06/22 18:38:20"), 110));
            task2.AddSession(new DurationSessionResult(DateTime.Parse("2018/06/22 18:00:00"), DateTime.Parse("2018/06/22 18:30:00")));
            task3.AddSession(new PercentSessionResult(DateTime.Parse("2018/06/22 18:00:00"), DateTime.Parse("2018/06/22 18:30:00"), 50));

            Assert.That(goal.PercentComplete, Is.EqualTo(50));
        }
Exemplo n.º 3
0
        private PercentGoalTask CreatePercentGoalTask(double percentCompleted, int weighting)
        {
            PercentGoalTask task = new PercentGoalTask();

            task.AddSession(new Sessions.PercentSessionResult(DateTime.Now.Subtract(new TimeSpan(0, 5, 0)), DateTime.Now, percentCompleted));
            task.Weighting = weighting;

            return(task);
        }
Exemplo n.º 4
0
        public void Test()
        {
            var goal  = new Goal();
            var task1 = new PercentGoalTask {
                Id = 1, CreateDate = DateTime.Now, Title = "Task 1", Weighting = 50
            };
            var task2 = new PercentGoalTask {
                Id = 1, CreateDate = DateTime.Now, Title = "Task 2", Weighting = 50
            };

            goal.AddTask(task1);
            goal.AddTask(task2);

            task1.AddSession(new PercentSessionResult(DateTime.Now, DateTime.Now.AddMinutes(10), 50));
            task2.AddSession(new PercentSessionResult(DateTime.Now, DateTime.Now.AddMinutes(10), 50));

            Assert.That(goal.PercentComplete, Is.EqualTo(50));
            Assert.That(goal.IsConsideredComplete, Is.False);
        }