Exemple #1
0
        public void Enumeration_ReturnsAllVertices(int w, int h, string expected)
        {
            var graph  = new ChessHorsePathGraph(w, h);
            var result = string.Join(",", graph.Select(s => $"{s.X}{s.Y}"));

            Assert.AreEqual(expected, result);
        }
        public void FindChessHorsePathBetweenTwoPoints_FindsShortestPathBetweenTwoPoints(int sx, int sy, int ex, int ey,
                                                                                         string expected)
        {
            var actual = string.Join(";",
                                     ChessHorsePathGraph.FindChessHorsePathBetweenTwoPoints(new Cell(sx, sy), new Cell(ex, ey))
                                     .Select(s => $"{s.X},{s.Y}"));

            Assert.AreEqual(expected, actual);
        }
Exemple #3
0
        public void GetEdges_ReturnsProperEdges(int x, int y, string expected)
        {
            var graph  = new ChessHorsePathGraph(5, 5);
            var result = new List <string>();
            var cell   = new Cell(x, y);

            foreach (var edge in graph.GetEdges(cell))
            {
                Assert.AreEqual(cell, edge.FromVertex);
                Assert.AreEqual(1, edge.Weight);

                result.Add($"{edge.ToVertex.X}{edge.ToVertex.Y}");
            }

            var actual = string.Join(",", result);

            Assert.AreEqual(expected, actual);
        }
Exemple #4
0
        public void GetEdges_ThrowsException_ForInvalidCell(int x, int y)
        {
            var graph = new ChessHorsePathGraph(2, 3);

            Assert.Throws <ArgumentException>(() => graph.GetEdges(new Cell(x, y)));
        }
Exemple #5
0
        public void SupportsPotentialWeightEvaluation_ReturnsFalse()
        {
            var graph = new ChessHorsePathGraph(10, 10);

            Assert.IsFalse(graph.SupportsPotentialWeightEvaluation);
        }
Exemple #6
0
        public void IsReadOnly_ReturnsTrue()
        {
            var graph = new ChessHorsePathGraph(2, 3);

            Assert.IsTrue(graph.IsReadOnly);
        }
Exemple #7
0
        public void IsDirected_ReturnsFalse()
        {
            var graph = new ChessHorsePathGraph(2, 3);

            Assert.IsFalse(graph.IsDirected);
        }