Exemple #1
0
        public void TestMasterJob()
        {
            var policy = new CommandPolicy()
            {
                ChannelId = "default", JobSchedulesEnabled = true, CommandContractAttributeInherit = true, JobScheduleAttributeInherit = true
            };
            //Default state.
            var harness = new CommandHarness <MasterJobCommandTop>(policy);

            harness.MasterJobNegotiationEnable();

            harness.Start();

            Assert.IsTrue(harness.RegisteredSchedules.Count == 1);
            Assert.IsTrue(harness.Dependencies.Scheduler.Count == 2);
            Assert.IsTrue(harness.RegisteredCommandMethods.Count == 2);

            Assert.IsFalse(harness.HasCommand(("one", "base")));
            Assert.IsFalse(harness.HasSchedule("1base"));

            //Wait for the master job to go live.
            harness.MasterJobStart();

            //Check that the MasterJob commands and schedules have been registered.
            Assert.IsTrue(harness.RegisteredSchedules.Count == 2);
            Assert.IsTrue(harness.Dependencies.Scheduler.Count == 3);
            Assert.IsTrue(harness.RegisteredCommandMethods.Count == 3);

            Assert.IsTrue(harness.HasCommand(("one", "top")));
            Assert.IsTrue(harness.HasSchedule("1top"));

            Assert.IsTrue(harness.HasCommand(("one", "base")));
            Assert.IsTrue(harness.HasSchedule("1base"));

            //Stop the master job
            harness.MasterJobStop();

            //Check that the master job commands have been removed.
            Assert.IsTrue(harness.RegisteredSchedules.Count == 1);
            Assert.IsTrue(harness.Dependencies.Scheduler.Count == 2);
            Assert.IsTrue(harness.RegisteredCommandMethods.Count == 2);

            Assert.IsFalse(harness.HasCommand(("one", "base")));
            Assert.IsFalse(harness.HasSchedule("1base"));
        }