예제 #1
0
        public void AddWithNullSchedule()
        {
            var collection = ScheduleStorage.CreateInstanceWithoutTimeline();

            Assert.Throws <ArgumentNullException>(
                () => collection.Add(null, "a", "b"));
        }
예제 #2
0
        public void ExecuteWithUnknownSchedule()
        {
            var distributor = new ScheduleDistributor(
                ScheduleStorage.CreateInstanceWithoutTimeline(),
                (s, id, e) => null);

            Assert.Throws <UnknownScheduleException>(() => distributor.Execute(new ScheduleId()));
        }
예제 #3
0
        public void UpdateWithNullSchedule()
        {
            var collection = ScheduleStorage.CreateInstanceWithoutTimeline();
            var schedule   = new Mock <ISchedule>();

            var info = collection.Add(schedule.Object, "a", "b");

            Assert.Throws <ArgumentNullException>(() => collection.Update(info.Id, null));
        }
예제 #4
0
        public void UpdateWithUnknownId()
        {
            var collection = ScheduleStorage.CreateInstanceWithoutTimeline();
            var schedule   = new Mock <ISchedule>();

            collection.Add(schedule.Object, "a", "b");
            var otherSchedule = new Mock <ISchedule>();

            Assert.Throws <UnknownScheduleException>(() => collection.Update(new ScheduleId(), otherSchedule.Object));
        }
예제 #5
0
        public void Add()
        {
            var collection = ScheduleStorage.CreateInstanceWithoutTimeline();
            var schedule   = new Mock <ISchedule>();

            var info = collection.Add(schedule.Object, "a", "b");

            Assert.AreSame(info, collection.Information(info.Id));
            Assert.AreSame(schedule.Object, collection.Schedule(info.Id));
        }
예제 #6
0
        public void Contains()
        {
            var collection = ScheduleStorage.CreateInstanceWithoutTimeline();
            var schedule   = new Mock <ISchedule>();

            var info = collection.Add(schedule.Object, "a", "b");

            Assert.IsTrue(collection.Contains(info.Id));
            Assert.IsFalse(collection.Contains(new ScheduleId()));
            Assert.IsFalse(collection.Contains(null));
        }
예제 #7
0
        public void ExecuteWithAlreadyRunningSchedule()
        {
            var action1              = new ScheduleElementId();
            var action2              = new ScheduleElementId();
            var exitCondition        = new ScheduleElementId();
            var passThroughCondition = new ScheduleElementId();
            var subSchedule          = new ScheduleId();

            var schedule = BuildSchedule(
                action1,
                action2,
                subSchedule,
                exitCondition,
                passThroughCondition);

            var knownSchedules = ScheduleStorage.CreateInstanceWithoutTimeline();
            var scheduleInfo   = knownSchedules.Add(
                schedule,
                "a",
                "b");

            var executor = new Mock <IExecuteSchedules>();

            int index = 0;
            Func <ISchedule, ScheduleId, ScheduleExecutionInfo, IExecuteSchedules> builder =
                (s, id, e) =>
            {
                index++;
                return(executor.Object);
            };

            var distributor      = new ScheduleDistributor(knownSchedules, builder);
            var returnedExecutor = distributor.Execute(scheduleInfo.Id);

            Assert.AreSame(executor.Object, returnedExecutor);
            Assert.AreEqual(1, index);

            var otherReturnedExecutor = distributor.Execute(scheduleInfo.Id);

            Assert.AreSame(executor.Object, otherReturnedExecutor);
            Assert.AreEqual(1, index);
        }
예제 #8
0
        public void Update()
        {
            var collection = ScheduleStorage.CreateInstanceWithoutTimeline();
            var schedule   = new Mock <ISchedule>();

            var info = collection.Add(schedule.Object, "a", "b");

            Assert.AreSame(schedule.Object, collection.Schedule(info.Id));

            var otherSchedule = new Mock <ISchedule>();

            collection.Update(info.Id, otherSchedule.Object);
            var otherInfo = collection.Information(info.Id);

            Assert.AreEqual(info.Id, otherInfo.Id);
            Assert.AreEqual(info.Name, otherInfo.Name);
            Assert.AreEqual(info.Description, otherInfo.Description);

            Assert.AreSame(otherSchedule.Object, collection.Schedule(info.Id));
        }
예제 #9
0
        public void ExecuteInProcess()
        {
            var action1              = new ScheduleElementId();
            var action2              = new ScheduleElementId();
            var exitCondition        = new ScheduleElementId();
            var passThroughCondition = new ScheduleElementId();
            var subSchedule          = new ScheduleId();

            var schedule = BuildSchedule(
                action1,
                action2,
                subSchedule,
                exitCondition,
                passThroughCondition);

            var knownSchedules = ScheduleStorage.CreateInstanceWithoutTimeline();
            var scheduleInfo   = knownSchedules.Add(
                schedule,
                "a",
                "b");

            ISchedule storedSchedule = null;
            var       executor       = new Mock <IExecuteSchedules>();
            Func <ISchedule, ScheduleId, ScheduleExecutionInfo, IExecuteSchedules> builder =
                (s, i, e) =>
            {
                storedSchedule = s;
                return(executor.Object);
            };

            var distributor      = new ScheduleDistributor(knownSchedules, builder);
            var returnedExecutor = distributor.Execute(scheduleInfo.Id);

            Assert.AreSame(executor.Object, returnedExecutor);
            VerifySchedule(schedule, storedSchedule);
        }
예제 #10
0
        public void RemoveWithNullId()
        {
            var collection = ScheduleStorage.CreateInstanceWithoutTimeline();

            Assert.DoesNotThrow(() => collection.Remove(null));
        }