public void ContainsTransitionFactories()
        {
            var graph = new TransitionFactoryImplicitGraph <CloneableTestVertex, Edge <CloneableTestVertex> >();

            var vertex1  = new CloneableTestVertex("1");
            var factory1 = new TestTransitionFactory <CloneableTestVertex>(vertex1, Enumerable.Empty <Edge <CloneableTestVertex> >());

            Assert.IsFalse(graph.ContainsTransitionFactory(null));
            Assert.IsFalse(graph.ContainsTransitionFactory(factory1));

            graph.AddTransitionFactory(factory1);

            Assert.IsFalse(graph.ContainsTransitionFactory(null));
            Assert.IsTrue(graph.ContainsTransitionFactory(factory1));

            var vertex2  = new CloneableTestVertex("2");
            var factory2 = new TestTransitionFactory <CloneableTestVertex>(vertex2, Enumerable.Empty <Edge <CloneableTestVertex> >());

            graph.AddTransitionFactory(factory2);

            Assert.IsFalse(graph.ContainsTransitionFactory(null));
            Assert.IsTrue(graph.ContainsTransitionFactory(factory1));
            Assert.IsTrue(graph.ContainsTransitionFactory(factory2));

            graph.RemoveTransitionFactory(factory1);

            Assert.IsFalse(graph.ContainsTransitionFactory(null));
            Assert.IsFalse(graph.ContainsTransitionFactory(factory1));
            Assert.IsTrue(graph.ContainsTransitionFactory(factory2));
        }
        public void OutEdge_Throws()
        {
            var graph1 = new TransitionFactoryImplicitGraph <CloneableTestVertex, Edge <CloneableTestVertex> >();

            OutEdge_NullThrows_Test(graph1);

            var graph2 = new TransitionFactoryImplicitGraph <CloneableTestVertex, Edge <CloneableTestVertex> >();

            var vertex1 = new CloneableTestVertex("1");
            var vertex2 = new CloneableTestVertex("2");

            // ReSharper disable ReturnValueOfPureMethodIsNotUsed
            Assert.Throws <VertexNotFoundException>(() => graph2.OutEdge(vertex1, 0));

            var factory1 = new TestTransitionFactory <CloneableTestVertex>(
                vertex1,
                Enumerable.Empty <Edge <CloneableTestVertex> >());

            graph2.AddTransitionFactory(factory1);
            graph2.AddTransitionFactory(
                new TestTransitionFactory <CloneableTestVertex>(vertex2, Enumerable.Empty <Edge <CloneableTestVertex> >()));
            AssertIndexOutOfRange(() => graph2.OutEdge(vertex1, 0));

            graph2.RemoveTransitionFactory(factory1);
            graph2.AddTransitionFactory(
                new TestTransitionFactory <CloneableTestVertex>(vertex1, new[] { new Edge <CloneableTestVertex>(vertex1, vertex2) }));
            AssertIndexOutOfRange(() => graph2.OutEdge(vertex1, 5));
            // ReSharper restore ReturnValueOfPureMethodIsNotUsed
        }
        public void RemoveTransitionFactories()
        {
            var graph = new TransitionFactoryImplicitGraph <CloneableTestVertex, Edge <CloneableTestVertex> >();

            Assert.IsFalse(graph.RemoveTransitionFactory(null));

            var vertex1  = new CloneableTestVertex("1");
            var vertex2  = new CloneableTestVertex("2");
            var vertex3  = new CloneableTestVertex("3");
            var factory1 = new TestTransitionFactory <CloneableTestVertex>(vertex1, Enumerable.Empty <Edge <CloneableTestVertex> >());
            var factory2 = new TestTransitionFactory <CloneableTestVertex>(vertex2, Enumerable.Empty <Edge <CloneableTestVertex> >());
            var factory3 = new TestTransitionFactory <CloneableTestVertex>(vertex3, Enumerable.Empty <Edge <CloneableTestVertex> >());

            graph.AddTransitionFactories(new[] { factory1, factory2 });

            Assert.IsFalse(graph.ContainsTransitionFactory(null));
            Assert.IsTrue(graph.ContainsTransitionFactory(factory1));
            Assert.IsTrue(graph.ContainsTransitionFactory(factory2));

            Assert.IsFalse(graph.RemoveTransitionFactory(factory3));
            Assert.IsTrue(graph.RemoveTransitionFactory(factory1));
            Assert.IsFalse(graph.RemoveTransitionFactory(factory1));
            Assert.IsTrue(graph.RemoveTransitionFactory(factory2));

            var factory4 = new TestTransitionFactory <CloneableTestVertex>(
                vertex1,
                new[]
            {
                new Edge <CloneableTestVertex>(vertex1, vertex2),
                new Edge <CloneableTestVertex>(vertex1, vertex3)
            });

            graph.AddTransitionFactory(factory4);
            Assert.IsTrue(graph.ContainsTransitionFactory(factory4));

            // ReSharper disable once ReturnValueOfPureMethodIsNotUsed
            graph.OutEdges(vertex1);    // Force exploration from vertex1

            Assert.IsTrue(graph.RemoveTransitionFactory(factory4));
        }