コード例 #1
0
        public void Create()
        {
            var index  = 10;
            var vertex = new SynchronizationEndVertex(index);

            Assert.AreEqual(index, vertex.Index);
        }
コード例 #2
0
        /// <summary>
        /// Adds a vertex that indicates the end of a synchronization block.
        /// </summary>
        /// <param name="startPoint">The vertex that forms the start point of the block.</param>
        /// <returns>The vertex that indicates the end of a synchronization block.</returns>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="startPoint"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="UnknownScheduleVertexException">
        ///     Thrown if <paramref name="startPoint"/> is not part of the current schedule.
        /// </exception>
        public SynchronizationEndVertex AddSynchronizationEnd(SynchronizationStartVertex startPoint)
        {
            {
                Lokad.Enforce.Argument(() => startPoint);
                Lokad.Enforce.With<UnknownScheduleVertexException>(
                    m_Schedule.ContainsVertex(startPoint),
                    Resources.Exceptions_Messages_UnknownScheduleVertex);
            }

            var result = new SynchronizationEndVertex(m_Schedule.VertexCount);
            m_Schedule.AddVertex(result);

            return result;
        }
コード例 #3
0
        private static Schedule BuildSchedule(
            ScheduleElementId action1,
            ScheduleElementId action2,
            ScheduleId scheduleId,
            ScheduleElementId exitCondition,
            ScheduleElementId passThroughCondition)
        {
            var variable = new Mock<IScheduleVariable>();

            // Making a schedule that looks like:
            // start --> node1 -----------------------> node2 -> end
            //            ^                              |
            //            |-- node5 <-- node4 <-- node3<-|
            //                           ^  |
            //                    node7--|  |->  node6
            //                      ^              |
            //                      |--------------|
            Schedule schedule = null;
            {
                var graph = new BidirectionalGraph<IScheduleVertex, ScheduleEdge>();

                var start = new StartVertex(1);
                graph.AddVertex(start);

                var end = new EndVertex(2);
                graph.AddVertex(end);

                var vertex1 = new ExecutingActionVertex(3, action1);
                graph.AddVertex(vertex1);

                var vertex2 = new ExecutingActionVertex(4, action2);
                graph.AddVertex(vertex2);

                var vertex3 = new SynchronizationStartVertex(5, new IScheduleVariable[] { variable.Object });
                graph.AddVertex(vertex3);

                var vertex4 = new ExecutingActionVertex(6, action2);
                graph.AddVertex(vertex4);

                var vertex5 = new SynchronizationEndVertex(7);
                graph.AddVertex(vertex5);

                var vertex6 = new SubScheduleVertex(8, scheduleId);
                graph.AddVertex(vertex6);

                var vertex7 = new InsertVertex(9);
                graph.AddVertex(vertex7);

                graph.AddEdge(new ScheduleEdge(start, vertex1));
                graph.AddEdge(new ScheduleEdge(vertex1, vertex2));

                graph.AddEdge(new ScheduleEdge(vertex2, end, exitCondition));
                graph.AddEdge(new ScheduleEdge(vertex2, vertex3));

                graph.AddEdge(new ScheduleEdge(vertex3, vertex4));

                graph.AddEdge(new ScheduleEdge(vertex4, vertex5, passThroughCondition));
                graph.AddEdge(new ScheduleEdge(vertex4, vertex6));

                graph.AddEdge(new ScheduleEdge(vertex5, vertex1));
                graph.AddEdge(new ScheduleEdge(vertex6, vertex7));
                graph.AddEdge(new ScheduleEdge(vertex7, vertex4));

                schedule = new Schedule(graph, start, end);
            }

            return schedule;
        }