public void New_PercentGoalTask_Has_0_EffortWeighting()
        {
            var task = new PercentGoalTask();

            task.Title = "Task 1";
            Assert.That(task.Weighting, Is.EqualTo(0));
        }
        public void New_PercentGoalTask_Has_0_MinutesPracticed()
        {
            var task = new PercentGoalTask();

            task.Title = "Task 1";
            Assert.That(task.MinutesPracticed, Is.EqualTo(0));
        }
        public void New_PercentGoalTask_Has_0_PercentCompleted()
        {
            var task = new PercentGoalTask();

            task.Title = "Task 1";
            Assert.That(task.PercentCompleted, Is.EqualTo(0));
        }
        public void New_PercentGoalTask_StartDate_IsNull()
        {
            var task = new PercentGoalTask();

            task.Title = "Task 1";
            Assert.That(task.StartDate, Is.Null);
        }
        public void New_PercentGoalTask_CreateDate_IsSet()
        {
            var task = new PercentGoalTask();

            task.Title = "Task 1";
            Assert.That(task.CreateDate, Is.Not.EqualTo(DateTime.MinValue));
        }
Example #6
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);
        }
Example #7
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));
        }
Example #8
0
        private BaseTask GetTaskFromRecord(TaskRecord taskRecord)
        {
            BaseTask task = null;

            if (taskRecord.Type == Metronome)
            {
                task       = new MetronomeGoalTask();
                task.Id    = taskRecord.Id;
                task.Title = taskRecord.Title;
            }
            else if (taskRecord.Type == Duration)
            {
                task       = new DurationGoalTask();
                task.Id    = taskRecord.Id;
                task.Title = taskRecord.Title;
            }
            else if (taskRecord.Type == Percent)
            {
                task       = new PercentGoalTask();
                task.Id    = taskRecord.Id;
                task.Title = taskRecord.Title;
            }
            else if (taskRecord.Type == Aggregate)
            {
                // https://www.c-sharpcorner.com/UploadFile/c5c6e2/populate-a-treeview-dynamically/
                // https://github.com/vectors36/dynamic_treeview_sqlite_winform
                task       = new AggregateTask();
                task.Id    = taskRecord.Id;
                task.Title = taskRecord.Title;
            }
            return(task);
        }
Example #9
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);
        }
Example #10
0
        public void Weighting_Single_MetronomeGoalTask_Added_To_Task_Creates_100_Percent_Weighting()
        {
            var goal = new Goal();
            var task = new PercentGoalTask
            {
                Title     = "Task 1",
                Weighting = 100
            };

            goal.AddTask(task);
            Assert.That(task.Weighting, Is.EqualTo(100));
        }
Example #11
0
        public void Goal_Add_PercentTask_Adds_Task_Successfully()
        {
            Goal goal     = new Goal();
            var  goalTask = new PercentGoalTask
            {
                Title = "Title 1"
            };

            Assert.That(goalTask, Is.TypeOf <PercentGoalTask>());
            Assert.IsTrue(goalTask.Id == -1);
            Assert.That(goalTask.Title, Is.EqualTo("Title 1"));
        }
        public void One_PercentGoalTask_Equals_Another_PercentGoalTask_Correctly()
        {
            var task = new PercentGoalTask();

            task.Id    = 23;
            task.Title = "Hello World";

            var anotherTask = new PercentGoalTask();

            anotherTask.Id    = 23;
            anotherTask.Title = "Goodbye World";

            Assert.That(task, Is.EqualTo(anotherTask));
        }
        public void Existing_PercentGoalTask_Presents_Last_Percent_Completed_Value()
        {
            List <PercentSessionResult> results = new List <PercentSessionResult>()
            {
                new PercentSessionResult(DateTime.Parse("2018/06/22 18:00:00"), DateTime.Parse("2018/06/22 18:05:00"), 40),
                new PercentSessionResult(DateTime.Parse("2018/06/22 18:10:00"), DateTime.Parse("2018/06/22 18:15:00"), 50)
            };

            var task = new PercentGoalTask();

            task.Title      = "Task 1";
            task.CreateDate = DateTime.Parse("2018/06/18 18:33:20");
            task.AddSessionRange(results);

            Assert.That(task.PercentCompleted, Is.EqualTo(50));
        }
        public void Existing_PercentGoalTask_With_Adds_Up_SessionResult_Minutes_Correctly()
        {
            List <PercentSessionResult> results = new List <PercentSessionResult>()
            {
                new PercentSessionResult(DateTime.Parse("2018/06/22 18:00:00"), DateTime.Parse("2018/06/22 18:05:00"), 40),
                new PercentSessionResult(DateTime.Parse("2018/06/22 18:10:00"), DateTime.Parse("2018/06/22 18:15:00"), 50)
            };

            var task = new PercentGoalTask();

            task.Title      = "Task 1";
            task.CreateDate = DateTime.Parse("2018/06/18 18:33:20");
            task.AddSessionRange(results);

            Assert.That(task.MinutesPracticed, Is.EqualTo(10));
        }
        public void Existing_PercentGoalTask_Supplies_Correct_StartDate_From_SessionList()
        {
            DateTime expectedStartTime = DateTime.Parse("2018/06/22 18:00:00");

            List <PercentSessionResult> results = new List <PercentSessionResult>()
            {
                new PercentSessionResult(DateTime.Parse("2018/06/22 18:00:00"), DateTime.Parse("2018/06/22 18:05:00"), 70),
                new PercentSessionResult(DateTime.Parse("2018/06/22 18:10:00"), DateTime.Parse("2018/06/22 18:15:00"), 55)
            };


            var task = new PercentGoalTask();

            task.Title      = "Task 1";
            task.CreateDate = DateTime.Parse("2018/03/18 18:01:20");
            task.AddSessionRange(results);

            Assert.That(task.StartDate, Is.EqualTo(expectedStartTime));
        }
Example #16
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);
        }