Beispiel #1
0
        public void ShouldGetOverallProgressWhenJobContainsMultipleTask()
        {
            var task1          = new TaskMock();
            var task2          = new TaskMock();
            var taskCollection = new TaskCollectionMock();

            taskCollection.Add(task1);
            taskCollection.Add(task2);

            var job = new JobMock();

            job.Tasks = taskCollection;

            task1.Progress = 0;
            task2.Progress = 0;
            Assert.AreEqual(0, job.GetOverallProgress());

            task1.Progress = 25;
            task2.Progress = 0;
            Assert.AreEqual(12.5, job.GetOverallProgress());

            task1.Progress = 25;
            task2.Progress = 50;
            Assert.AreEqual(37.5, job.GetOverallProgress());

            task1.Progress = 50;
            task2.Progress = 50;
            Assert.AreEqual(50, job.GetOverallProgress());

            task1.Progress = 75;
            task2.Progress = 25;
            Assert.AreEqual(50, job.GetOverallProgress());

            task1.Progress = 75;
            task2.Progress = 50;
            Assert.AreEqual(62.5, job.GetOverallProgress());

            task1.Progress = 50;
            task2.Progress = 100;
            Assert.AreEqual(75, job.GetOverallProgress());

            task1.Progress = 100;
            task2.Progress = 75;
            Assert.AreEqual(87.5, job.GetOverallProgress());

            task1.Progress = 100;
            task2.Progress = 100;
            Assert.AreEqual(100, job.GetOverallProgress());
        }
Beispiel #2
0
        public void ShouldGetOverallProgressWhenJobContainsSingleTask()
        {
            var task           = new TaskMock();
            var taskCollection = new TaskCollectionMock();

            taskCollection.Add(task);

            var job = new JobMock();

            job.Tasks = taskCollection;

            task.Progress = 0;
            Assert.AreEqual(0, job.GetOverallProgress());

            task.Progress = 25;
            Assert.AreEqual(25, job.GetOverallProgress());

            task.Progress = 75;
            Assert.AreEqual(75, job.GetOverallProgress());

            task.Progress = 100;
            Assert.AreEqual(100, job.GetOverallProgress());
        }