public void AddActionWithExistingAction() { var owner = new Mock <IOwnScheduleDefinitions>(); ScheduleElementId id = null; var scheduleBuilder = new Mock <IBuildFixedSchedules>(); { scheduleBuilder.Setup(s => s.AddExecutingAction(It.IsAny <ScheduleElementId>())) .Callback <ScheduleElementId>(s => id = s) .Returns <ScheduleElementId>(s => new ExecutingActionVertex(0, s)); } var builder = new ScheduleDefinitionBuilder(owner.Object, scheduleBuilder.Object); var firstRegistration = new ScheduleActionRegistrationId(typeof(string), 0, "a"); var secondRegistration = new ScheduleActionRegistrationId(typeof(string), 0, "a"); var firstVertex = builder.AddExecutingAction(firstRegistration); var first = id; id = null; var secondVertex = builder.AddExecutingAction(secondRegistration); Assert.IsNotNull(firstVertex); Assert.IsNotNull(secondVertex); Assert.AreEqual(first, id); }
public void AddActionWithExistingAction() { var owner = new Mock<IOwnScheduleDefinitions>(); ScheduleElementId id = null; var scheduleBuilder = new Mock<IBuildFixedSchedules>(); { scheduleBuilder.Setup(s => s.AddExecutingAction(It.IsAny<ScheduleElementId>())) .Callback<ScheduleElementId>(s => id = s) .Returns<ScheduleElementId>(s => new ExecutingActionVertex(0, s)); } var builder = new ScheduleDefinitionBuilder(owner.Object, scheduleBuilder.Object); var firstRegistration = new ScheduleActionRegistrationId(typeof(string), 0, "a"); var secondRegistration = new ScheduleActionRegistrationId(typeof(string), 0, "a"); var firstVertex = builder.AddExecutingAction(firstRegistration); var first = id; id = null; var secondVertex = builder.AddExecutingAction(secondRegistration); Assert.IsNotNull(firstVertex); Assert.IsNotNull(secondVertex); Assert.AreEqual(first, id); }
public void Register() { var graph = new BidirectionalGraph <IScheduleVertex, ScheduleEdge>(); var start = new StartVertex(1); graph.AddVertex(start); var end = new EndVertex(2); graph.AddVertex(end); graph.AddEdge(new ScheduleEdge(start, end)); var schedule = new Schedule(graph, start, end); var scheduleBuilder = new Mock <IBuildFixedSchedules>(); { scheduleBuilder.Setup(s => s.Build()) .Returns(schedule); scheduleBuilder.Setup(s => s.AddExecutingAction(It.IsAny <ScheduleElementId>())) .Returns <ScheduleElementId>(s => new ExecutingActionVertex(0, s)); } var actionId = new ScheduleActionRegistrationId(typeof(string), 0, "a"); var conditionId = new ScheduleConditionRegistrationId(typeof(string), 0, "a"); var owner = new Mock <IOwnScheduleDefinitions>(); { owner.Setup( o => o.StoreSchedule( It.IsAny <ISchedule>(), It.IsAny <Dictionary <ScheduleActionRegistrationId, ScheduleElementId> >(), It.IsAny <Dictionary <ScheduleConditionRegistrationId, ScheduleElementId> >())) .Callback <ISchedule, Dictionary <ScheduleActionRegistrationId, ScheduleElementId>, Dictionary <ScheduleConditionRegistrationId, ScheduleElementId> >( (s, a, c) => { Assert.That(a.Keys, Is.EquivalentTo(new List <ScheduleActionRegistrationId> { actionId })); Assert.That(c.Keys, Is.EquivalentTo(new List <ScheduleConditionRegistrationId> { conditionId })); }); } var builder = new ScheduleDefinitionBuilder(owner.Object, scheduleBuilder.Object); var vertex = builder.AddExecutingAction(actionId); builder.LinkToEnd(vertex, conditionId); builder.Register(); }
public void AddAction() { var owner = new Mock <IOwnScheduleDefinitions>(); ScheduleElementId id = null; var scheduleBuilder = new Mock <IBuildFixedSchedules>(); { scheduleBuilder.Setup(s => s.AddExecutingAction(It.IsAny <ScheduleElementId>())) .Callback <ScheduleElementId>(s => id = s) .Returns <ScheduleElementId>(s => new ExecutingActionVertex(0, s)); } var builder = new ScheduleDefinitionBuilder(owner.Object, scheduleBuilder.Object); var registrationId = new ScheduleActionRegistrationId(typeof(string), 0, "a"); var vertex = builder.AddExecutingAction(registrationId); Assert.IsNotNull(vertex); Assert.IsNotNull(id); }
public void AddAction() { var owner = new Mock<IOwnScheduleDefinitions>(); ScheduleElementId id = null; var scheduleBuilder = new Mock<IBuildFixedSchedules>(); { scheduleBuilder.Setup(s => s.AddExecutingAction(It.IsAny<ScheduleElementId>())) .Callback<ScheduleElementId>(s => id = s) .Returns<ScheduleElementId>(s => new ExecutingActionVertex(0, s)); } var builder = new ScheduleDefinitionBuilder(owner.Object, scheduleBuilder.Object); var registrationId = new ScheduleActionRegistrationId(typeof(string), 0, "a"); var vertex = builder.AddExecutingAction(registrationId); Assert.IsNotNull(vertex); Assert.IsNotNull(id); }
public void Register() { var graph = new BidirectionalGraph<IScheduleVertex, ScheduleEdge>(); var start = new StartVertex(1); graph.AddVertex(start); var end = new EndVertex(2); graph.AddVertex(end); graph.AddEdge(new ScheduleEdge(start, end)); var schedule = new Schedule(graph, start, end); var scheduleBuilder = new Mock<IBuildFixedSchedules>(); { scheduleBuilder.Setup(s => s.Build()) .Returns(schedule); scheduleBuilder.Setup(s => s.AddExecutingAction(It.IsAny<ScheduleElementId>())) .Returns<ScheduleElementId>(s => new ExecutingActionVertex(0, s)); } var actionId = new ScheduleActionRegistrationId(typeof(string), 0, "a"); var conditionId = new ScheduleConditionRegistrationId(typeof(string), 0, "a"); var owner = new Mock<IOwnScheduleDefinitions>(); { owner.Setup( o => o.StoreSchedule( It.IsAny<ISchedule>(), It.IsAny<Dictionary<ScheduleActionRegistrationId, ScheduleElementId>>(), It.IsAny<Dictionary<ScheduleConditionRegistrationId, ScheduleElementId>>())) .Callback<ISchedule, Dictionary<ScheduleActionRegistrationId, ScheduleElementId>, Dictionary<ScheduleConditionRegistrationId, ScheduleElementId>>( (s, a, c) => { Assert.That(a.Keys, Is.EquivalentTo(new List<ScheduleActionRegistrationId> { actionId })); Assert.That(c.Keys, Is.EquivalentTo(new List<ScheduleConditionRegistrationId> { conditionId })); }); } var builder = new ScheduleDefinitionBuilder(owner.Object, scheduleBuilder.Object); var vertex = builder.AddExecutingAction(actionId); builder.LinkToEnd(vertex, conditionId); builder.Register(); }