Пример #1
0
        //used when a task can't fill a day
        private void FillInAllPossible(LeafTask task, int hours)
        {
            hoursFilled += hours;
            hours = 0;

            CreateWorkDayByTask(task);
        }
Пример #2
0
        protected override void Visit(LeafTask task)
        {
            int hours = task.EstimatedRemainingHours;

            if (hoursFilled != 0)
                hours = FillInRemainingHours(task, hours);

            while (hours >= 8)
                hours = FillInFullDay(task, hours);

            if (hours > 0)
                FillInAllPossible(task, hours);
        }
Пример #3
0
        public void TestLeafConstructor()
        {
            LeafTask task = new LeafTask(0, "TASK", "Test Task", 15);

            Assert.That(task.Description, Is.EqualTo("Test Task"));
            Assert.That(task.Label, Is.EqualTo("TASK"));
            Assert.That(task.ID, Is.EqualTo(0));
            Assert.That(task.HoursWorked, Is.EqualTo(0));
            Assert.That(task.OriginalEstimatedHours, Is.EqualTo(15));
            Assert.That(task.RevisedEstimatedHours, Is.EqualTo(15));
            Assert.That(task.EstimatedRemainingHours, Is.EqualTo(15));
            Assert.That(task.PercentComplete, Is.EqualTo(0));
            Assert.That(task.AssignedEngineers.Count, Is.EqualTo(0));
        }
Пример #4
0
        public void TestLeafEstimatedHours(int hours)
        {
            LeafTask task = new LeafTask(0, "TASK", "Test Task", hours);

            if (hours > 0)
            {
                Assert.That(task.OriginalEstimatedHours, Is.EqualTo(Math.Abs(hours)));
                Assert.That(task.RevisedEstimatedHours, Is.EqualTo(Math.Abs(hours)));
            }
            else
            {
                Assert.That(task.OriginalEstimatedHours, Is.EqualTo(0));
                Assert.That(task.RevisedEstimatedHours, Is.EqualTo(0));
            }
        }
Пример #5
0
        public void TestImportExportLeafTask()
        {
            LeafTask leaf = new LeafTask(0, "TSK", "Test", 15);
            leaf.AddEngineer(new Engineer() { ID = 0, HoursAvailable = 10, Name = "Test" });
            ser.Export(leaf, PATH);

            LeafTask newLeaf = ser.Import(PATH) as LeafTask;

            Assert.That(leaf.Description, Is.EqualTo(newLeaf.Description));
            Assert.That(leaf.HoursWorked, Is.EqualTo(newLeaf.HoursWorked));
            Assert.That(leaf.ID, Is.EqualTo(newLeaf.ID));
            Assert.That(leaf.Label, Is.EqualTo(newLeaf.Label));
            Assert.That(leaf.OriginalEstimatedHours, Is.EqualTo(newLeaf.OriginalEstimatedHours));
            Assert.That(leaf.RevisedEstimatedHours, Is.EqualTo(newLeaf.RevisedEstimatedHours));
            CollectionAssert.AreEqual(leaf.AssignedEngineers, newLeaf.AssignedEngineers);
        }
Пример #6
0
        protected override void Visit(LeafTask task)
        {
            tabs += "\t";

            writer.WriteLine($"{tabs}Task - {task.Label} - {task.Description}");
            writer.WriteLine($"{tabs}  Estimated Hours: {task.RevisedEstimatedHours}");
            writer.WriteLine($"{tabs}  Percent Complete: {task.PercentComplete:0%}");
            writer.WriteLine($"{tabs}  Hours Remaining: {task.EstimatedRemainingHours}");
            writer.WriteLine($"{tabs}  Hours Worked: {task.HoursWorked}");
            writer.WriteLine($"{tabs}  Days to Complete: {task.EstimatedDaysToComplete}");
            writer.WriteLine($"{tabs}  Engineers:");
            foreach (Engineer e in task.AssignedEngineers)
                writer.WriteLine($"{tabs}\t{e.Name}");

            tabs = tabs.Remove(0, 1);
        }
Пример #7
0
        public void TestLeafEngineers()
        {
            LeafTask task = new LeafTask(0, "TASK", "Test Task", 15);
            Engineer e = new Engineer() { ID = 0, Name = "Test", HoursAvailable = 24 };

            task.AddEngineer(e);
            task.AddEngineer(null);

            Assert.That(task.AssignedEngineers.Count, Is.EqualTo(1));
            Assert.That(task.AssignedEngineers[0], Is.EqualTo(e));

            task.RemoveEngineer(null);
            task.RemoveEngineer(e);

            Assert.That(task.AssignedEngineers.Count, Is.EqualTo(0));
        }
Пример #8
0
        //creates a work day if it doesn't already exist and assigns engineers
        private void CreateWorkDayByTask(LeafTask task)
        {
            bool addDay = false;
            WorkDay day;
            day = schedule.WorkDays.Where(wd => wd.Day == currentDay).SingleOrDefault();

            if (day == null)
            {
                day = new WorkDay(currentDay);
                addDay = true;
            }

            PopulateWorkDayWithEngineers(task, day);

            if (addDay)
                schedule.WorkDays.Add(day);
        }
Пример #9
0
        public void SetUp()
        {
            parallelTask = new ParallelParentTask(0, "TASK", "Test");
            sequentialTask = new SequentialParentTask(0, "TASK", "Test");
            emptyTask = new SequentialParentTask(0, "TASK", "Test");

            leaf1 = new LeafTask(1, "LEAF1", "Awesome Task", HOURS);
            leaf2 = new LeafTask(2, "LEAF2", "More Awesome Task", HOURS);

            e = new Engineer() { ID = 0, HoursAvailable = HOURS / 2, Name = "Test" };
            e2 = new Engineer() { ID = 1, HoursAvailable = HOURS / 2, Name = "Test" };

            leaf1.AddEngineer(e);
            leaf2.AddEngineer(e2);

            parallelTask.AddTask(leaf1);
            parallelTask.AddTask(leaf2);

            sequentialTask.AddTask(leaf1);
            sequentialTask.AddTask(leaf1);
        }
Пример #10
0
        public void TestLeafEstimatedDays()
        {
            LeafTask task = new LeafTask(0, "TASK", "Test Task", 15);
            Engineer e = new Engineer() { ID = 0, Name = "Test", HoursAvailable = 2 };
            Engineer e2 = new Engineer() { ID = 0, Name = "Test", HoursAvailable = 3 };

            task.AddEngineer(e);
            task.AddEngineer(e2);

            Assert.That(task.EstimatedDaysToComplete, Is.EqualTo(3));

            task.HoursWorked = 8;

            Assert.That(task.EstimatedRemainingHours, Is.EqualTo(7));
            Assert.That(task.EstimatedDaysToComplete, Is.EqualTo(2));

            task.RemoveEngineer(e);
            task.RemoveEngineer(e2);

            Assert.That(task.EstimatedDaysToComplete, Is.EqualTo(-1));
        }
Пример #11
0
 protected override void Visit(LeafTask task)
 {
     days += task.EstimatedDaysToComplete;
 }
Пример #12
0
 protected abstract void Visit(LeafTask task);
Пример #13
0
 protected override void Visit(LeafTask task)
 {
     sumPercent += task.PercentComplete;
     numOfPercents++;
 }
Пример #14
0
        //used when a task can fill a full day
        private int FillInFullDay(LeafTask task, int hours)
        {
            hours -= 8 * task.AssignedEngineers.Count;

            CreateWorkDayByTask(task);

            currentDay++;

            return hours;
        }
Пример #15
0
 protected override void Visit(LeafTask task)
 {
     if (task.AssignedEngineers.Contains(target))
         assignedTasks.Add(task);
 }
Пример #16
0
        public int TestLeafHoursWorked(int hoursWorked)
        {
            LeafTask task = new LeafTask(0, "TASK", "Test Task", 15);
            task.HoursWorked = hoursWorked;

            return task.HoursWorked;
        }
Пример #17
0
 //assigns task to an engineer in the given work day
 private void PopulateWorkDayWithEngineers(LeafTask task, WorkDay day)
 {
     foreach (Engineer e in task.AssignedEngineers)
     {
         if (!day.AssignedTasks.ContainsKey(e))
         {
             List<Task> tasks = new List<Task>();
             tasks.Add(task);
             day.AssignedTasks.Add(e, tasks);
         }
         else
         {
             day.AssignedTasks[e].Add(task);
         }
     }
 }
Пример #18
0
        //used when a task can fill the rest of a day
        private int FillInRemainingHours(LeafTask task, int hours)
        {
            int remainingHours = 8 - hoursFilled;
            hours -= remainingHours;
            hoursFilled = 0;

            WorkDay day = schedule.WorkDays[currentDay++];

            PopulateWorkDayWithEngineers(task, day);

            return hours;
        }
Пример #19
0
 protected override void Visit(LeafTask task)
 {
     assignedEngineers.AddRange(task.AssignedEngineers);
 }
Пример #20
0
        public int TestLeafEstimatedRemaingHours(int totalHours, int hoursWorked)
        {
            LeafTask task = new LeafTask(0, "TASK", "Test Task", totalHours);
            task.HoursWorked = hoursWorked;

            return task.EstimatedRemainingHours;
        }
Пример #21
0
 protected override void Visit(LeafTask task)
 {
     hours += task.OriginalEstimatedHours;
 }
Пример #22
0
 protected override void Visit(LeafTask task)
 {
     hours += task.EstimatedRemainingHours;
 }
Пример #23
0
 protected override void Visit(LeafTask task)
 {
     hours += task.RevisedEstimatedHours;
 }
Пример #24
0
        public double TestLeafPercentComplete(int totalHours, int hoursWorked)
        {
            LeafTask task = new LeafTask(0, "TASK", "Test Task", totalHours);
            task.HoursWorked = hoursWorked;

            return task.PercentComplete;
        }