Ejemplo n.º 1
0
        public void GetNextLowestCostNeighbour_ReturnsNull_WhenStartItemNotFound(Node <string> startNode)
        {
            var testGraph = CreateWeightedTestGraph();

            var result = GraphFunctions.GetNextLowestCostNeighbour(testGraph, startNode);

            Assert.AreEqual(new ValueTuple <Node, int?>(null, null), result);
        }
Ejemplo n.º 2
0
        public void GetNextLowestCostNeighbour_ReturnsLowestNode_WhenStartNodeFound(int startNodeIndex, int[] searchedNodeIndexes, int expectedResultNodeIndex, int expectedResultWeight)
        {
            var testGraph = CreateWeightedTestGraph();
            ValueTuple <Node, int> expectedResult = new ValueTuple <Node, int>(testGraph.Nodes[expectedResultNodeIndex], expectedResultWeight);
            List <Node>            searchedNodes  = new List <Node>();

            foreach (var index in searchedNodeIndexes)
            {
                searchedNodes.Add(testGraph.Nodes[index]);
            }

            var result = GraphFunctions.GetNextLowestCostNeighbour(testGraph, testGraph.Nodes[startNodeIndex], searchedNodes);

            Assert.AreEqual(expectedResult, result);
        }
Ejemplo n.º 3
0
        public void GetNextLowestCostNeighbour_ThrowsNullArgumentException_WhenSearchItemIsNull()
        {
            Graph testGraph = new Graph(new List <Edge>(), new List <Node>());

            Assert.That(() => GraphFunctions.GetNextLowestCostNeighbour(testGraph, null), Throws.ArgumentNullException);
        }
Ejemplo n.º 4
0
        public void GetNextLowestCostNeighbour_ThrowsNullArgumentException_WhenGraphIsNull()
        {
            Graph testGraph = null;

            Assert.That(() => GraphFunctions.GetNextLowestCostNeighbour(testGraph, new Node <string>("Payload")), Throws.ArgumentNullException);
        }