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 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();
        }