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)); }
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); }
public void New_MetronomeGoalTask_Has_0_EffortWeighting() { var task = new MetronomeGoalTask(); task.Title = "Task 1"; task.StartSpeed = 80; task.TargetSpeed = 120; Assert.That(task.Weighting, Is.EqualTo(0)); }
public void New_MetronomeGoalTask_Has_0_PercentCompleted() { var task = new MetronomeGoalTask(); task.Title = "Task 1"; task.StartSpeed = 80; task.TargetSpeed = 120; Assert.That(task.PercentCompleted, Is.EqualTo(0)); }
public void New_MetronomeGoalTask_Has_0_MinutesPracticed() { var task = new MetronomeGoalTask(); task.Title = "Task 1"; task.StartSpeed = 80; task.TargetSpeed = 120; Assert.That(task.MinutesPracticed, Is.EqualTo(0)); }
public void New_MetronomeGoalTask_CreateDate_IsSet() { var task = new MetronomeGoalTask(); task.Title = "Task 1"; task.StartSpeed = 80; task.TargetSpeed = 120; Assert.That(task.CreateDate, Is.Not.EqualTo(DateTime.MinValue)); }
public void New_MetronomeGoalTask_StartDate_IsNull() { var task = new MetronomeGoalTask(); task.Title = "Task 1"; task.StartSpeed = 80; task.TargetSpeed = 120; Assert.That(task.StartDate, Is.Null); }
public void Goal_Add_MetronomeTask_Adds_Task_Successfully() { Goal goal = new Goal(); var goalTask = new MetronomeGoalTask { StartSpeed = 80, TargetSpeed = 90, Title = "Title 1" }; Assert.That(goalTask, Is.TypeOf <MetronomeGoalTask>()); Assert.IsTrue(goalTask.Id == -1); Assert.That(goalTask.Title, Is.EqualTo("Title 1")); }
public void One_MetronomeGoalTask_Equals_Another_MetronomeGoalTask_Correctly() { var task = new MetronomeGoalTask(); task.Id = 23; task.Title = "Hello World"; var anotherTask = new MetronomeGoalTask(); anotherTask.Id = 23; anotherTask.Title = "Goodbye World"; Assert.That(task, Is.EqualTo(anotherTask)); }
public void Goal_AddTask_With_Weighting_That_Exceeds_Limit_Throws_Exception() { Goal goal = new Goal(); var task1 = new MetronomeGoalTask(); task1.Title = "Metronome Task"; task1.StartSpeed = 100; task1.TargetSpeed = 120; task1.Weighting = 101; TestDelegate proc = () => goal.AddTask(task1); Assert.That(proc, Throws.TypeOf <ArgumentOutOfRangeException>()); }
public void Existing_MetronomeGoalTask_With_Empty_ResultList_Is_Zero_Percent_Completed() { List <MetronomeSessionResult> results = new List <MetronomeSessionResult>() { }; MetronomeGoalTask task = new MetronomeGoalTask(); task.Title = "Task 1"; task.StartSpeed = 60; task.TargetSpeed = 100; task.CreateDate = DateTime.Parse("2018/06/22 18:33:20"); task.AddSessionRange(results); Assert.That(task.PercentCompleted, Is.EqualTo(0)); }
public void Existing_MetronomeGoalTask_With_Adds_Up_SessionResult_Minutes_Correctly() { List <MetronomeSessionResult> results = new List <MetronomeSessionResult>() { new MetronomeSessionResult(DateTime.Parse("2018/06/22 18:00:00"), DateTime.Parse("2018/06/22 18:05:00"), 40), new MetronomeSessionResult(DateTime.Parse("2018/06/22 18:10:00"), DateTime.Parse("2018/06/22 18:25:00"), 45) }; MetronomeGoalTask task = new MetronomeGoalTask(); task.Title = "Task 1"; task.StartSpeed = 60; task.TargetSpeed = 100; task.CreateDate = DateTime.Parse("2018/06/22 18:33:20"); task.AddSessionRange(results); Assert.That(task.MinutesPracticed, Is.EqualTo(20)); }
public void Existing_MetronomeGoalTask_With_Start_Speed_Bigger_Than_Current_Speed_Is_Zero_Percent_Completed() { List <MetronomeSessionResult> results = new List <MetronomeSessionResult>() { new MetronomeSessionResult(DateTime.Parse("2018/06/22 18:00:00"), DateTime.Parse("2018/06/22 18:05:00"), 40), new MetronomeSessionResult(DateTime.Parse("2018/06/22 18:10:00"), DateTime.Parse("2018/06/22 18:25:00"), 45) }; MetronomeGoalTask task = new MetronomeGoalTask(); task.Title = "Task 1"; task.StartSpeed = 60; task.TargetSpeed = 100; task.CreateDate = DateTime.Parse("2018/06/22 18:33:20"); task.AddSessionRange(results); Assert.That(task.PercentCompleted, Is.EqualTo(0)); }
public void Existing_MetronomeGoalTask_Supplies_Correct_StartDate_From_SessionList() { DateTime expectedStartTime = DateTime.Parse("2018/06/22 18:00:00"); List <MetronomeSessionResult> results = new List <MetronomeSessionResult>() { new MetronomeSessionResult(DateTime.Parse("2018/06/22 18:00:00"), DateTime.Parse("2018/06/22 18:05:00"), 60), new MetronomeSessionResult(DateTime.Parse("2018/06/22 18:10:00"), DateTime.Parse("2018/06/22 18:25:00"), 60) }; MetronomeGoalTask task = new MetronomeGoalTask(); task.Title = "Task 1"; task.StartSpeed = 60; task.TargetSpeed = 70; task.CreateDate = DateTime.Parse("2018/03/18 18:01:20"); task.AddSessionRange(results); Assert.That(task.StartDate, Is.EqualTo(expectedStartTime)); }
public void Existing_MetronomeGoalTask_Only_Half_Way_To_Target_Returns_50_Percent_Completed() { // The idea is that if one starts off with a metronome speed of 50, but your // target metronome speed is 90, and your currently checked off speed is 70, then your percentage will be... // ((90 - 70) / (90 - 50)) * 100 ... List <MetronomeSessionResult> results = new List <MetronomeSessionResult>() { new MetronomeSessionResult(DateTime.Parse("2018/06/22 18:00:00"), DateTime.Parse("2018/06/22 18:05:00"), 60), new MetronomeSessionResult(DateTime.Parse("2018/06/22 18:10:00"), DateTime.Parse("2018/06/22 18:25:00"), 80) }; var task = new MetronomeGoalTask(); task.Title = "Task 1"; task.StartSpeed = 60; task.TargetSpeed = 100; task.CreateDate = DateTime.Parse("2018/06/22 18:33:20"); task.AddSessionRange(results); Assert.That(task.PercentCompleted, Is.EqualTo(50)); }