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_DurationGoalTask_Has_0_EffortWeighting() { var task = new DurationGoalTask(); task.Title = "Task 1"; task.TargetMinutes = 100; Assert.That(task.Weighting, Is.EqualTo(0)); }
public void New_DurationGoalTask_Has_0_TargetUnit() { var task = new DurationGoalTask(); task.Title = "Task 1"; task.TargetMinutes = 100; Assert.That(task.MinutesPracticed, Is.EqualTo(0)); }
public void New_DurationGoalTask_CreateDate_IsSet() { var task = new DurationGoalTask(); task.Title = "Task 1"; task.TargetMinutes = 100; Assert.That(task.CreateDate, Is.Not.EqualTo(DateTime.MinValue)); }
public void New_DurationGoalTask_Has_0_PercentCompleted() { var task = new DurationGoalTask(); task.Title = "Task 1"; task.TargetMinutes = 100; Assert.That(task.PercentCompleted, Is.EqualTo(0)); }
public void New_DurationGoalTask_StartDate_IsNull() { var task = new DurationGoalTask(); task.Title = "Task 1"; task.TargetMinutes = 100; Assert.That(task.StartDate, Is.Null); }
public void Goal_Add_DurationTask_Adds_Task_Successfully() { Goal goal = new Goal(); var goalTask = new DurationGoalTask { TargetMinutes = 100, Title = "Title 1" }; Assert.That(goalTask, Is.TypeOf <DurationGoalTask>()); Assert.IsTrue(goalTask.Id == -1); Assert.That(goalTask.Title, Is.EqualTo("Title 1")); }
public void Weighting_Single_DurationGoalTask_Added_To_Task_Creates_100_Percent_Weighting() { var goal = new Goal(); var goalTask = new DurationGoalTask { TargetMinutes = 100, Title = "Title 1", Weighting = 100 }; goal.AddTask(goalTask); Assert.That(goalTask.Weighting, Is.EqualTo(100)); }
public void One_DurationGoalTask_Equals_Another_DurationGoalTask_Correctly() { var task = new DurationGoalTask(); task.Id = 23; task.Title = "Hello World"; var anotherTask = new DurationGoalTask(); anotherTask.Id = 23; anotherTask.Title = "Goodbye World"; Assert.That(task, Is.EqualTo(anotherTask)); }
public void Existing_DurationGoalTask_Adds_Up_SessionResult_Minutes_Correctly() { List <DurationSessionResult> results = new List <DurationSessionResult>() { new DurationSessionResult(DateTime.Parse("2018/06/22 18:00:00"), DateTime.Parse("2018/06/22 18:05:00")), new DurationSessionResult(DateTime.Parse("2018/06/22 18:10:00"), DateTime.Parse("2018/06/22 18:25:00")) }; var task = new DurationGoalTask(); task.Title = "Task 1"; task.TargetMinutes = 100; task.AddSessionRange(results); Assert.That(task.MinutesPracticed, Is.EqualTo(20)); }
public void Existing_DurationGoalTask_With_20_Min_Out_Of_60_Min_Is_33_Percent() { List <DurationSessionResult> results = new List <DurationSessionResult>() { new DurationSessionResult(DateTime.Parse("2018/06/22 18:00:00"), DateTime.Parse("2018/06/22 18:05:00")), new DurationSessionResult(DateTime.Parse("2018/06/22 18:10:00"), DateTime.Parse("2018/06/22 18:25:00")) }; var task = new DurationGoalTask(); task.Title = "Task 1"; task.TargetMinutes = 60; task.AddSessionRange(results); Assert.That(task.PercentCompleted, Is.InRange(33.3, 33.34)); }
public void DurationGoalTask_With_More_Minutes_Than_Target_Returns_100_Percent() { List <DurationSessionResult> results = new List <DurationSessionResult>() { new DurationSessionResult(DateTime.Parse("2018/06/22 18:33:20"), DateTime.Parse("2018/06/22 18:40:20")), new DurationSessionResult(DateTime.Parse("2018/06/23 14:33:20"), DateTime.Parse("2018/06/23 18:52:20")) }; var task = new DurationGoalTask(); task.Title = "Task 1"; task.TargetMinutes = 100; task.AddSessionRange(results); Assert.That(task.PercentCompleted, Is.EqualTo(100)); }
public void Existing_DurationGoalTask_Supplies_Correct_StartDate_From_SessionList() { DateTime expectedStartTime = DateTime.Parse("2018/06/22 18:00:00"); List <DurationSessionResult> results = new List <DurationSessionResult>() { new DurationSessionResult(DateTime.Parse("2018/06/22 18:00:00"), DateTime.Parse("2018/06/22 18:05:00")), new DurationSessionResult(DateTime.Parse("2018/06/22 18:10:00"), DateTime.Parse("2018/06/22 18:25:00")) }; var task = new DurationGoalTask(); task.Title = "Task 1"; task.TargetMinutes = 100; task.AddSessionRange(results); Assert.That(task.StartDate, Is.EqualTo(expectedStartTime)); }