Exemplo n.º 1
0
        //used when a task can't fill a day
        private void FillInAllPossible(LeafTask task, int hours)
        {
            hoursFilled += hours;
            hours = 0;

            CreateWorkDayByTask(task);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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));
        }
Exemplo n.º 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));
            }
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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));
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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));
        }
Exemplo n.º 11
0
 protected override void Visit(LeafTask task)
 {
     days += task.EstimatedDaysToComplete;
 }
Exemplo n.º 12
0
 protected abstract void Visit(LeafTask task);
Exemplo n.º 13
0
 protected override void Visit(LeafTask task)
 {
     sumPercent += task.PercentComplete;
     numOfPercents++;
 }
Exemplo n.º 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;
        }
Exemplo n.º 15
0
 protected override void Visit(LeafTask task)
 {
     if (task.AssignedEngineers.Contains(target))
         assignedTasks.Add(task);
 }
Exemplo n.º 16
0
        public int TestLeafHoursWorked(int hoursWorked)
        {
            LeafTask task = new LeafTask(0, "TASK", "Test Task", 15);
            task.HoursWorked = hoursWorked;

            return task.HoursWorked;
        }
Exemplo n.º 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);
         }
     }
 }
Exemplo n.º 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;
        }
Exemplo n.º 19
0
 protected override void Visit(LeafTask task)
 {
     assignedEngineers.AddRange(task.AssignedEngineers);
 }
Exemplo n.º 20
0
        public int TestLeafEstimatedRemaingHours(int totalHours, int hoursWorked)
        {
            LeafTask task = new LeafTask(0, "TASK", "Test Task", totalHours);
            task.HoursWorked = hoursWorked;

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

            return task.PercentComplete;
        }