public void AddWithNullSchedule() { var collection = ScheduleStorage.CreateInstanceWithoutTimeline(); Assert.Throws <ArgumentNullException>( () => collection.Add(null, "a", "b")); }
public void ExecuteWithUnknownSchedule() { var distributor = new ScheduleDistributor( ScheduleStorage.CreateInstanceWithoutTimeline(), (s, id, e) => null); Assert.Throws <UnknownScheduleException>(() => distributor.Execute(new ScheduleId())); }
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)); }
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)); }
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)); }
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)); }
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); }
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)); }
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); }
public void RemoveWithNullId() { var collection = ScheduleStorage.CreateInstanceWithoutTimeline(); Assert.DoesNotThrow(() => collection.Remove(null)); }