Ejemplo n.º 1
0
        public void EssenceGetsCleanedOnUpdate()
        {
            var originJob = ActiveJob();
            int essenceAmount;

            JobRepository.Add(originJob);
            Assert.That(JobRepository.ActiveJobs().Count(), Is.EqualTo(1));
            Assert.That(JobRepository.DoneJobs(), Is.Empty);
            Assert.That(JobRepository.WaitingJobs(), Is.Empty);
            var jobFromRepo = JobRepository.Get(originJob.Urn);

            jobFromRepo.Plan.GetCurrentTask().State = ExecutionState.Done;
            jobFromRepo.Plan.MoveToNextTask();
            JobRepository.Update(jobFromRepo);
            using (var db = new MarvinEntities())
            {
                essenceAmount = db.essence.Count();
            }
            //There should only be four essencefiles (two job essence and two task essence)
            Assert.That(essenceAmount, Is.EqualTo(4));
        }
Ejemplo n.º 2
0
        public void PrioritySortTest()
        {
            var jobDue1DayLow = CreateNewWfsJob(dueDate: TimeProvider.GetUtcNow().AddDays(1));

            jobDue1DayLow.Priority = Priority.low;
            JobRepository.Add(jobDue1DayLow);
            var jobDue1DayHigh = CreateNewWfsJob(dueDate: TimeProvider.GetUtcNow().AddDays(1));

            jobDue1DayHigh.Priority = Priority.high;
            JobRepository.Add(jobDue1DayHigh);
            var jobDueNowDayLow = CreateNewWfsJob();

            jobDueNowDayLow.Priority = Priority.low;
            JobRepository.Add(jobDueNowDayLow);
            var jobDueNowDayHigh = CreateNewWfsJob();

            jobDueNowDayHigh.Priority = Priority.high;
            JobRepository.Add(jobDueNowDayHigh);
            Assert.That(JobRepository.WaitingJobs().Count(), Is.EqualTo(4));

            var wfsPluginMock  = CreateWfsMock("1");
            var wfsPluginMock2 = CreateWfsMock("2");

            wfsPluginMock.SetupGet(p => p.Busy).Returns(false);
            wfsPluginMock.Setup(p => p.CheckAndEstimate(It.IsAny <ExecutionTask>())).Returns(true);
            wfsPluginMock2.SetupGet(p => p.Busy).Returns(false);
            wfsPluginMock2.Setup(p => p.CheckAndEstimate(It.IsAny <ExecutionTask>())).Returns(true);
            var planner = new SimplePlanner(new List <IPlugin> {
                wfsPluginMock.Object, wfsPluginMock2.Object
            }, JobRepository, Logging, _callBackService.Object);

            planner.Calculate();
            var activeJob = JobRepository.ActiveJobs().First(m => m.Id == jobDueNowDayHigh.Id);

            Assert.That(activeJob.Urn, Is.EqualTo(jobDueNowDayHigh.Urn));
            activeJob.Plan.GetCurrentTask().State = ExecutionState.Done;
            activeJob.Plan.MoveToNextTask();
            JobRepository.Update(activeJob);

            planner.Calculate();
            activeJob = JobRepository.ActiveJobs().First(m => m.Id == jobDue1DayHigh.Id);
            Assert.That(activeJob.Urn, Is.EqualTo(jobDue1DayHigh.Urn));
            activeJob.Plan.GetCurrentTask().State = ExecutionState.Done;
            activeJob.Plan.MoveToNextTask();
            JobRepository.Update(activeJob);

            planner.Calculate();
            activeJob = JobRepository.ActiveJobs().First(m => m.Id == jobDueNowDayLow.Id);
            Assert.That(activeJob.Urn, Is.EqualTo(jobDueNowDayLow.Urn));
            activeJob.Plan.GetCurrentTask().State = ExecutionState.Done;
            activeJob.Plan.MoveToNextTask();
            JobRepository.Update(activeJob);

            planner.Calculate();
            activeJob = JobRepository.ActiveJobs().First(m => m.Id == jobDue1DayLow.Id);
            Assert.That(activeJob.Urn, Is.EqualTo(jobDue1DayLow.Urn));
            activeJob.Plan.GetCurrentTask().State = ExecutionState.Done;
            activeJob.Plan.MoveToNextTask();
            JobRepository.Update(activeJob);

            Assert.That(JobRepository.WaitingJobs(), Is.Empty);
            Assert.That(JobRepository.ActiveJobs(), Is.Empty);
            Assert.That(JobRepository.DoneJobs().Count(), Is.EqualTo(4));
        }