public void LinkFromStartWithUnknownVertex() { var builder = new FixedScheduleBuilder(); var otherVertex = new InsertVertex(10); Assert.Throws <UnknownScheduleVertexException>(() => builder.LinkFromStart(otherVertex)); }
public void AddInsertPoint() { var builder = new FixedScheduleBuilder(); var insertVertex = builder.AddInsertPoint(); builder.LinkFromStart(insertVertex); builder.LinkToEnd(insertVertex); Assert.AreEqual(2, insertVertex.Index); var schedule = builder.Build(); Assert.AreEqual(3, schedule.Vertices.Count()); Assert.IsTrue(AreVerticesEqual(schedule.Start, schedule.Vertices.ElementAt(0))); Assert.IsTrue(AreVerticesEqual(insertVertex, schedule.Vertices.ElementAt(1))); Assert.IsTrue(AreVerticesEqual(schedule.End, schedule.Vertices.ElementAt(2))); }
public void InsertInWithNoMoreRemainingInserts() { var builder = new FixedScheduleBuilder(); var insertVertex = builder.AddInsertPoint(1); builder.LinkFromStart(insertVertex); builder.LinkToEnd(insertVertex); var markHistoryVertex1 = new MarkHistoryVertex(10); var newInserts = builder.InsertIn(insertVertex, markHistoryVertex1); Assert.IsNull(newInserts.Item1); Assert.IsNull(newInserts.Item2); }
public void InsertInWithSubSchedule() { var conditionId1 = new ScheduleElementId(); var conditionId2 = new ScheduleElementId(); var builder = new FixedScheduleBuilder(); var insertVertex = builder.AddInsertPoint(); builder.LinkFromStart(insertVertex, conditionId1); builder.LinkToEnd(insertVertex, conditionId2); var scheduleId = new ScheduleId(); builder.InsertIn(insertVertex, scheduleId); var schedule = builder.Build(); int index = 0; var vertexTypes = new List <Type> { typeof(StartVertex), typeof(InsertVertex), typeof(SubScheduleVertex), typeof(InsertVertex), typeof(EndVertex) }; var conditions = new List <ScheduleElementId> { conditionId1, null, null, conditionId2 }; schedule.TraverseAllScheduleVertices( schedule.Start, (vertex, edges) => { Assert.AreEqual(vertexTypes[index], vertex.GetType()); if (index < conditions.Count) { Assert.AreEqual(1, edges.Count()); Assert.AreEqual(conditions[index], edges.First().Item1); } index++; return(true); }); }
public void AddInsertPoint() { var builder = new FixedScheduleBuilder(); var insertVertex = builder.AddInsertPoint(); builder.LinkFromStart(insertVertex); builder.LinkToEnd(insertVertex); Assert.AreEqual(2, insertVertex.Index); var schedule = builder.Build(); Assert.AreEqual(3, schedule.Vertices.Count()); Assert.IsTrue(AreVerticesEqual(schedule.Start, schedule.Vertices.ElementAt(0))); Assert.IsTrue(AreVerticesEqual(insertVertex, schedule.Vertices.ElementAt(1))); Assert.IsTrue(AreVerticesEqual(schedule.End, schedule.Vertices.ElementAt(2))); }
public void AddExecutingAction() { var actionId = new ScheduleElementId(); var builder = new FixedScheduleBuilder(); var actionVertex = builder.AddExecutingAction(actionId); builder.LinkFromStart(actionVertex); builder.LinkToEnd(actionVertex); Assert.AreEqual(actionId, actionVertex.ActionToExecute); Assert.AreEqual(2, actionVertex.Index); var schedule = builder.Build(); Assert.AreEqual(3, schedule.Vertices.Count()); Assert.IsTrue(AreVerticesEqual(schedule.Start, schedule.Vertices.ElementAt(0))); Assert.IsTrue(AreVerticesEqual(actionVertex, schedule.Vertices.ElementAt(1))); Assert.IsTrue(AreVerticesEqual(schedule.End, schedule.Vertices.ElementAt(2))); }
public void AddSubSchedule() { var scheduleId = new ScheduleId(); var builder = new FixedScheduleBuilder(); var subScheduleVertex = builder.AddSubSchedule(scheduleId); builder.LinkFromStart(subScheduleVertex); builder.LinkToEnd(subScheduleVertex); Assert.AreEqual(scheduleId, subScheduleVertex.ScheduleToExecute); Assert.AreEqual(2, subScheduleVertex.Index); var schedule = builder.Build(); Assert.AreEqual(3, schedule.Vertices.Count()); Assert.IsTrue(AreVerticesEqual(schedule.Start, schedule.Vertices.ElementAt(0))); Assert.IsTrue(AreVerticesEqual(subScheduleVertex, schedule.Vertices.ElementAt(1))); Assert.IsTrue(AreVerticesEqual(schedule.End, schedule.Vertices.ElementAt(2))); }
public void AddExecutingAction() { var actionId = new ScheduleElementId(); var builder = new FixedScheduleBuilder(); var actionVertex = builder.AddExecutingAction(actionId); builder.LinkFromStart(actionVertex); builder.LinkToEnd(actionVertex); Assert.AreEqual(actionId, actionVertex.ActionToExecute); Assert.AreEqual(2, actionVertex.Index); var schedule = builder.Build(); Assert.AreEqual(3, schedule.Vertices.Count()); Assert.IsTrue(AreVerticesEqual(schedule.Start, schedule.Vertices.ElementAt(0))); Assert.IsTrue(AreVerticesEqual(actionVertex, schedule.Vertices.ElementAt(1))); Assert.IsTrue(AreVerticesEqual(schedule.End, schedule.Vertices.ElementAt(2))); }
public void AddSynchronizationStartPoint() { var variable = new Mock <IScheduleVariable>(); var builder = new FixedScheduleBuilder(); var synchronizationVertex = builder.AddSynchronizationStart(new[] { variable.Object }); builder.LinkFromStart(synchronizationVertex); builder.LinkToEnd(synchronizationVertex); Assert.That(synchronizationVertex.VariablesToSynchronizeOn, Is.EquivalentTo(new[] { variable.Object })); Assert.AreEqual(2, synchronizationVertex.Index); var schedule = builder.Build(); Assert.AreEqual(3, schedule.Vertices.Count()); Assert.IsTrue(AreVerticesEqual(schedule.Start, schedule.Vertices.ElementAt(0))); Assert.IsTrue(AreVerticesEqual(synchronizationVertex, schedule.Vertices.ElementAt(1))); Assert.IsTrue(AreVerticesEqual(schedule.End, schedule.Vertices.ElementAt(2))); }
public void LinkFromStartWithUnknownVertex() { var builder = new FixedScheduleBuilder(); var otherVertex = new InsertVertex(10); Assert.Throws<UnknownScheduleVertexException>(() => builder.LinkFromStart(otherVertex)); }
public void InsertInWithSubSchedule() { var conditionId1 = new ScheduleElementId(); var conditionId2 = new ScheduleElementId(); var builder = new FixedScheduleBuilder(); var insertVertex = builder.AddInsertPoint(); builder.LinkFromStart(insertVertex, conditionId1); builder.LinkToEnd(insertVertex, conditionId2); var scheduleId = new ScheduleId(); builder.InsertIn(insertVertex, scheduleId); var schedule = builder.Build(); int index = 0; var vertexTypes = new List<Type> { typeof(StartVertex), typeof(InsertVertex), typeof(SubScheduleVertex), typeof(InsertVertex), typeof(EndVertex) }; var conditions = new List<ScheduleElementId> { conditionId1, null, null, conditionId2 }; schedule.TraverseAllScheduleVertices( schedule.Start, (vertex, edges) => { Assert.AreEqual(vertexTypes[index], vertex.GetType()); if (index < conditions.Count) { Assert.AreEqual(1, edges.Count()); Assert.AreEqual(conditions[index], edges.First().Item1); } index++; return true; }); }
public void InsertInWithNoMoreRemainingInserts() { var builder = new FixedScheduleBuilder(); var insertVertex = builder.AddInsertPoint(1); builder.LinkFromStart(insertVertex); builder.LinkToEnd(insertVertex); var markHistoryVertex1 = new MarkHistoryVertex(10); var newInserts = builder.InsertIn(insertVertex, markHistoryVertex1); Assert.IsNull(newInserts.Item1); Assert.IsNull(newInserts.Item2); }
public void AddSynchronizationStartPoint() { var variable = new Mock<IScheduleVariable>(); var builder = new FixedScheduleBuilder(); var synchronizationVertex = builder.AddSynchronizationStart(new[] { variable.Object }); builder.LinkFromStart(synchronizationVertex); builder.LinkToEnd(synchronizationVertex); Assert.That(synchronizationVertex.VariablesToSynchronizeOn, Is.EquivalentTo(new[] { variable.Object })); Assert.AreEqual(2, synchronizationVertex.Index); var schedule = builder.Build(); Assert.AreEqual(3, schedule.Vertices.Count()); Assert.IsTrue(AreVerticesEqual(schedule.Start, schedule.Vertices.ElementAt(0))); Assert.IsTrue(AreVerticesEqual(synchronizationVertex, schedule.Vertices.ElementAt(1))); Assert.IsTrue(AreVerticesEqual(schedule.End, schedule.Vertices.ElementAt(2))); }
public void AddSubSchedule() { var scheduleId = new ScheduleId(); var builder = new FixedScheduleBuilder(); var subScheduleVertex = builder.AddSubSchedule(scheduleId); builder.LinkFromStart(subScheduleVertex); builder.LinkToEnd(subScheduleVertex); Assert.AreEqual(scheduleId, subScheduleVertex.ScheduleToExecute); Assert.AreEqual(2, subScheduleVertex.Index); var schedule = builder.Build(); Assert.AreEqual(3, schedule.Vertices.Count()); Assert.IsTrue(AreVerticesEqual(schedule.Start, schedule.Vertices.ElementAt(0))); Assert.IsTrue(AreVerticesEqual(subScheduleVertex, schedule.Vertices.ElementAt(1))); Assert.IsTrue(AreVerticesEqual(schedule.End, schedule.Vertices.ElementAt(2))); }