public void LinkToWithStartAndEndEqual()
        {
            var builder      = new FixedScheduleBuilder();
            var insertVertex = builder.AddInsertPoint();

            Assert.Throws <CannotLinkAVertexToItselfException>(() => builder.LinkTo(insertVertex, insertVertex));
        }
        public void LinkToWithUnknownEnd()
        {
            var builder      = new FixedScheduleBuilder();
            var insertVertex = builder.AddInsertPoint();
            var otherVertex  = new InsertVertex(10);

            Assert.Throws <UnknownScheduleVertexException>(() => builder.LinkTo(insertVertex, otherVertex));
        }
        public void InsertInWithKnownVertexToInsert()
        {
            var builder           = new FixedScheduleBuilder();
            var insertVertex      = builder.AddInsertPoint();
            var markHistoryVertex = builder.AddHistoryMarkingPoint();

            Assert.Throws <CannotInsertExistingVertexException>(
                () => builder.InsertIn(insertVertex, markHistoryVertex));
        }
        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 LinkToWithUnknownStart()
 {
     var builder = new FixedScheduleBuilder();
     var insertVertex = builder.AddInsertPoint();
     var otherVertex = new InsertVertex(10);
     Assert.Throws<UnknownScheduleVertexException>(() => builder.LinkTo(otherVertex, insertVertex));
 }
 public void LinkToWithStartAndEndEqual()
 {
     var builder = new FixedScheduleBuilder();
     var insertVertex = builder.AddInsertPoint();
     Assert.Throws<CannotLinkAVertexToItselfException>(() => builder.LinkTo(insertVertex, insertVertex));
 }
        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 InsertInWithKnownVertexToInsert()
 {
     var builder = new FixedScheduleBuilder();
     var insertVertex = builder.AddInsertPoint();
     var markHistoryVertex = builder.AddHistoryMarkingPoint();
     Assert.Throws<CannotInsertExistingVertexException>(
         () => builder.InsertIn(insertVertex, markHistoryVertex));
 }
 public void AddInsertPointWithInvalidCount()
 {
     var builder = new FixedScheduleBuilder();
     Assert.Throws<ArgumentOutOfRangeException>(() => builder.AddInsertPoint(0));
 }
        public void AddInsertPointWithInvalidCount()
        {
            var builder = new FixedScheduleBuilder();

            Assert.Throws <ArgumentOutOfRangeException>(() => builder.AddInsertPoint(0));
        }