Ejemplo n.º 1
0
        public void AddWithNullSchedule()
        {
            var collection = ScheduleStorage.CreateInstanceWithoutTimeline();

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

            Assert.Throws <UnknownScheduleException>(() => distributor.Execute(new ScheduleId()));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 10
0
        public void RemoveWithNullId()
        {
            var collection = ScheduleStorage.CreateInstanceWithoutTimeline();

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