Ejemplo n.º 1
0
        public void GetEdges_CorrectlyReports_Weight()
        {
            var graph = new StringNeighborhoodGraph(new[] { "a", "b" });

            // ReSharper disable once CompareOfFloatsByEqualityOperator
            Assert.IsTrue(graph.GetEdges("a").All(e => e.Weight == 1));
        }
Ejemplo n.º 2
0
        public void FindShortestPath_WillTraverseTheGraphInExpectedOrder()
        {
            var graph = new StringNeighborhoodGraph(new[] { "aa", "za", "zz", "zb", "ib", "i7", "17", "a6", "16" });

            TestHelper.AssertSequence(graph.FindShortestPath("aa", "17"),
                                      "aa", "a6", "16", "17");
        }
Ejemplo n.º 3
0
        public void GetEdges_ProperlyJoinsSingleLetterStrings([NotNull] string vertex, string expected)
        {
            var graph  = new StringNeighborhoodGraph(new[] { "a", "b", "c" });
            var actual = string.Join(",", graph.GetEdges(vertex).Select(s => s.ToVertex));

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 4
0
        public void GetEdges_ThrowsException_ForInvalidVertex()
        {
            var graph = new StringNeighborhoodGraph(new[] { "a", "b", "c" });

            Assert.Throws <ArgumentException>(() => graph.GetEdges("z"));
        }
Ejemplo n.º 5
0
        public void GetEdges_CorrectlyReports_FromVertex()
        {
            var graph = new StringNeighborhoodGraph(new[] { "a", "b" });

            Assert.IsTrue(graph.GetEdges("a").All(e => e.FromVertex == "a"));
        }
Ejemplo n.º 6
0
        public void Enumeration_ReturnsSingleVertex()
        {
            var graph = new StringNeighborhoodGraph(new[] { "test" });

            TestHelper.AssertSequence(graph, "test");
        }
Ejemplo n.º 7
0
        public void Enumeration_ReturnsNothing_ForEmptyGraph()
        {
            var graph = new StringNeighborhoodGraph(new string[] { });

            TestHelper.AssertSequence(graph);
        }
Ejemplo n.º 8
0
        public void Enumeration_ReturnsAllVertices()
        {
            var graph = new StringNeighborhoodGraph(new[] { "a", "b", "c" });

            TestHelper.AssertSequence(graph, "a", "b", "c");
        }
Ejemplo n.º 9
0
        public void SupportsPotentialWeightEvaluation_ReturnsFalse()
        {
            var graph = new StringNeighborhoodGraph(new[] { "a", "b", "c" });

            Assert.IsFalse(graph.SupportsPotentialWeightEvaluation);
        }