Esempio n. 1
0
        public void ON_ConvertPathToEdgeData_WHEN_Path_Does_Not_Exist_SHOULD_Throw_Exception()
        {
            // Arrange
            var uut = new SymbolGraph <string, string>(40, StringComparer.InvariantCultureIgnoreCase);

            TestEdgesFactory.Define(uut, v => v.Source + v.Destination,
                                    TestEdgesFactory.DefinitionSet.PathA2J | TestEdgesFactory.DefinitionSet.JA);

            uut.Freeze();

            // Act
            var _ = uut.ConvertPathToEdgeData("ADJF".AsStrings()).ToArray();
            // Assert handled by expected exception.
        }
Esempio n. 2
0
        public void ON_ConvertPathToEdgeData_WHEN_Path_Exists_SHOULD_Return_Path_Edge_Data()
        {
            // Arrange
            var uut = new SymbolGraph <string, string>(40, StringComparer.InvariantCultureIgnoreCase);

            TestEdgesFactory.Define(uut, v => v.Source + v.Destination,
                                    TestEdgesFactory.DefinitionSet.PathA2J | TestEdgesFactory.DefinitionSet.JA);

            uut.Freeze();

            // Act
            var edges = uut.ConvertPathToEdgeData("ABCD".AsStrings()).ToArray();

            // Assert
            CollectionAssert.AreEqual(EnumerableExtensions.Enumerate("AB", "BC", "CD").ToArray(), edges.ToArray());
        }
Esempio n. 3
0
        public void ON_GetPathTo_WHEN_Single_Path_Exist_SHOULD_Return_Proper_Path()
        {
            // Arrange
            var uut = new SymbolGraph <string, string>(40, StringComparer.InvariantCultureIgnoreCase);

            TestEdgesFactory.Define(uut, v => v.Source + v.Destination, TestEdgesFactory.DefinitionSet.PathA2J);

            uut.Freeze();

            var map = uut.GetSearchMapFrom("A");

            // Act
            var path = map.GetPathTo("J").ToArray();

            // Assert
            CollectionAssert.AreEqual(TestEdgesFactory.VertexSymbolsA2J, path);
        }
Esempio n. 4
0
        public void ON_GetPathTo_WHEN_Vertex_Does_Not_Exist_SHOULD_Return_Empty()
        {
            // Arrange
            var uut = new SymbolGraph <string, string>(40, StringComparer.InvariantCultureIgnoreCase);

            TestEdgesFactory.Define(uut, v => v.Source + v.Destination,
                                    TestEdgesFactory.DefinitionSet.PathA2J);

            uut.Freeze();

            var map = uut.GetSearchMapFrom("@");
            // Act
            var any = map.GetPathTo("!").Any();

            // Assert
            Assert.IsFalse(any);
        }
Esempio n. 5
0
        public void ON_GetPathTo_WHEN_Vertex_Self_Looped_SHOULD_Return_Buckle_Path()
        {
            // Arrange
            var uut = new SymbolGraph <string, string>(40, StringComparer.InvariantCultureIgnoreCase);

            TestEdgesFactory.Define(uut, v => v.Source + v.Destination,
                                    TestEdgesFactory.DefinitionSet.PathA2J | TestEdgesFactory.DefinitionSet.JA | TestEdgesFactory.DefinitionSet.SelfA2J);

            uut.Freeze();

            var map = uut.GetSearchMapFrom("B");
            // Act
            var path = map.GetPathTo("B").ToArray();

            // Assert
            CollectionAssert.AreEqual("BB".AsStrings().ToArray(), path);
        }
Esempio n. 6
0
        public void ON_GetPathTo_WHEN_Multiple_Paths_SHOULD_Return_Shortest_Path()
        {
            // Arrange
            var uut = new SymbolGraph <string, string>(40, StringComparer.InvariantCultureIgnoreCase);

            TestEdgesFactory.Define(uut, v => v.Source + v.Destination,
                                    TestEdgesFactory.DefinitionSet.PathA2J | TestEdgesFactory.DefinitionSet.EMFNBIGD);

            uut.Freeze();

            var map = uut.GetSearchMapFrom("A");
            // Act
            var path = map.GetPathTo("J").ToArray();

            // Assert
            CollectionAssert.AreEqual("ABIJ".AsStrings().ToArray(), path);
        }