public void DefaultBehaviorWithExistingProcess_WhenKillingExistingProcess_ProcessShouldBeKilled()
        {
            var taskManager = new TaskManagerBuilder(maxCapacity: 1)
                              .With <DefaultBehavior>()
                              .Build()
                              .WithExistingProcess();

            taskManager.Kill(
                taskManager.List().Single().Id.PID);

            taskManager
            .List().Should().BeEmpty();
        }
        public void DefaultBehavior_WhenAddingProcess_ProcessShouldBeAdded()
        {
            var taskManager = new TaskManagerBuilder(maxCapacity: 1)
                              .With <DefaultBehavior>()
                              .Build();

            var process = new Process(1, 2);

            taskManager.Add(process);

            taskManager
            .List().Should().Contain(process);
        }
        public void WhenKillingAll_AllShouldBeKilled()
        {
            var processA = new Process(1, 2, DateTime.UtcNow.AddMinutes(-15));
            var processB = new Process(2, 1, DateTime.UtcNow.AddMinutes(-10));

            var taskManager = new TaskManagerBuilder(maxCapacity: 2)
                              .With <DefaultBehavior>()
                              .Build()
                              .WithExistingProcess(processB)
                              .WithExistingProcess(processA);

            taskManager.KillAll();

            taskManager.List()
            .Should().BeEmpty();
        }
        public void WhenKillingByGroup_GroupShouldBeKilled()
        {
            var processA = new Process(1, 2, DateTime.UtcNow.AddMinutes(-15));
            var processB = new Process(2, 1, DateTime.UtcNow.AddMinutes(-10));

            var taskManager = new TaskManagerBuilder(maxCapacity: 2)
                              .With <DefaultBehavior>()
                              .Build()
                              .WithExistingProcess(processB)
                              .WithExistingProcess(processA);

            taskManager.KillGroup(2);

            taskManager.List()
            .Should().NotContain(processA);
        }
        public void WhenListingSortedByPriority_OrderShouldMatch()
        {
            var processA = new Process(1, 2, DateTime.UtcNow.AddMinutes(-15));
            var processB = new Process(2, 1, DateTime.UtcNow.AddMinutes(-10));

            var taskManager = new TaskManagerBuilder(maxCapacity: 2)
                              .With <DefaultBehavior>()
                              .Build()
                              .WithExistingProcess(processB)
                              .WithExistingProcess(processA);

            taskManager.List(SortBy.Priority)
            .Should().BeEquivalentTo(
                processB,
                processA);
        }
Esempio n. 6
0
        public void FIFOBehaviorAndCapacityIsFull_WhenAddingProcess_OldestShouldBeKilled()
        {
            var taskManager = new TaskManagerBuilder(maxCapacity: 1)
                              .With <FifoBehavior>()
                              .Build()
                              .WithExistingProcess();

            var oldProcess = taskManager.List().Single();
            var newProcess = new Process(1, 2);

            taskManager.Add(newProcess);

            taskManager
            .List().Should().Contain(newProcess)
            .And
            .NotContain(oldProcess);
        }
Esempio n. 7
0
        PriorityBehaviorAndCapacityIsFull_WhenAddingProcessWithLeastPriority_OldestShouldBeKeptNewShouldSkipped()
        {
            var processWithHigherPriority = new Process(1, 1);
            var processWithLowerPriority  = new Process(2, 5);

            var taskManager = new TaskManagerBuilder(maxCapacity: 1)
                              .With <PriorityBehavior>()
                              .Build()
                              .WithExistingProcess(processWithHigherPriority);

            taskManager.Add(processWithLowerPriority);

            taskManager.List()
            .Should().Contain(processWithHigherPriority)
            .And
            .NotContain(processWithLowerPriority);
        }
        public void DefaultBehaviorAndCapacityIsFull_WhenAddingProcess_ErrorShouldBeThrown()
        {
            var taskManager = new TaskManagerBuilder(maxCapacity: 1)
                              .With <DefaultBehavior>()
                              .Build()
                              .WithExistingProcess();

            var existing     = taskManager.List().Single();
            var processToAdd = new Process(1, 2);

            taskManager.Invoking(t => t.Add(processToAdd))
            .Should()
            .Throw <MaxCapacityOfProcessesReachedException>();

            taskManager
            .List().Should().Contain(existing)
            .And
            .NotContain(processToAdd);
        }