public void NoExceptionThrown_WhenVertexIsAccessibleFromRoot() { var scenario = new ContractScenario <int> { EdgesInGraph = new[] { new Edge <int>(1, 2) }, AccessibleVerticesFromRoot = new[] { 2 }, Root = 1, DoComputation = true }; IDistancesCollection <int> algorithm = CreateAlgorithmAndMaybeDoComputation(scenario); Assert.DoesNotThrow(() => { double _ = algorithm.GetDistance(2); }); }
public void ExceptionThrown_WhenAlgorithmHasNotYetBeenComputed() { var scenario = new ContractScenario <int> { EdgesInGraph = new[] { new Edge <int>(1, 2) }, SingleVerticesInGraph = new int[0], AccessibleVerticesFromRoot = new[] { 2 }, Root = 1, DoComputation = false }; IDistancesCollection <int> algorithm = CreateAlgorithmAndMaybeDoComputation(scenario); Assert.Throws <InvalidOperationException>(() => { double _ = algorithm.GetDistance(2); }); }
public void NoExceptionThrown_WhenVertexExistsButIsInaccessibleFromRoot() { var scenario = new ContractScenario <int> { EdgesInGraph = new[] { new Edge <int>(1, 2) }, SingleVerticesInGraph = new[] { 3 }, AccessibleVerticesFromRoot = new[] { 2 }, Root = 1, DoComputation = true }; IDistancesCollection <int> algorithm = CreateAlgorithmAndMaybeDoComputation(scenario); double _ = algorithm.GetDistance(3); }
public void ExceptionThrown_WhenTargetVertexIsNull() { var scenario = new ContractScenario <string> { EdgesInGraph = new[] { new Edge <string>("1", "2") }, SingleVerticesInGraph = new string[0], AccessibleVerticesFromRoot = new[] { "2" }, Root = "1", DoComputation = false }; IDistancesCollection <string> algorithm = CreateAlgorithmAndMaybeDoComputation(scenario); // ReSharper disable once AssignNullToNotNullAttribute Assert.Throws <ArgumentNullException>(() => { double _ = algorithm.GetDistance(null); }); }