Пример #1
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);
        }
Пример #2
0
        public void AggregateTask_Calculates_PercentComplete_Correctly_If_All_ChildTask_Weightings_Equal()
        {
            AggregateTask aggGoalTask = new AggregateTask();

            aggGoalTask.AddChildTask(CreatePercentGoalTask(percentCompleted: 25, weighting: 100));
            aggGoalTask.AddChildTask(CreatePercentGoalTask(percentCompleted: 50, weighting: 100));
            aggGoalTask.AddChildTask(CreatePercentGoalTask(percentCompleted: 75, weighting: 100));

            Assert.That(aggGoalTask.PercentCompleted, Is.InRange(49.9, 50));
        }
Пример #3
0
        public void AggregateTask_Calculates_PercentComplete_Correctly_If_All_ChildTask_Weightings_Equal_And_One_Is_Aggregate_Task()
        {
            AggregateTask childAggregateTask = new AggregateTask();

            childAggregateTask.Weighting = 100;

            childAggregateTask.AddChildTask(CreatePercentGoalTask(percentCompleted: 25, weighting: 100));
            childAggregateTask.AddChildTask(CreatePercentGoalTask(percentCompleted: 50, weighting: 100));
            childAggregateTask.AddChildTask(CreatePercentGoalTask(percentCompleted: 75, weighting: 100));

            AggregateTask parentAggregateTask = new AggregateTask();

            parentAggregateTask.AddChildTask(childAggregateTask);
            parentAggregateTask.AddChildTask(CreatePercentGoalTask(percentCompleted: 50, weighting: 100));

            Assert.That(parentAggregateTask.PercentCompleted, Is.InRange(49.9, 50));
        }
Пример #4
0
        public void SubTask()
        {
            var aTask = new AggregateTask <CountTask>
            {
                Tasks = new []
                {
                    new CountTask(),
                    new CountTask(),
                    new CountTask(),
                }
            };

            taskManager.Schedule(aTask);
            aTask.Wait();
            foreach (var task in aTask.Tasks)
            {
                Assert.AreEqual(1000, task.Count);
            }
        }