public void FailsForCollinearPoints() { var tests = new[,] { {new Vector(), new Vector(), new Vector()}, {new Vector(-1000, -1000), new Vector(), new Vector(1000, 1000)}, {new Vector(123, 0), new Vector(234, 0), new Vector(345, 0)}, {new Vector(0, 123), new Vector(0, 234), new Vector(0, 345)} }; for (int i = 0; i < tests.GetLength(0); i++) { Assert.Throws(typeof(CollinearPointsException), () => { Helpers.CircleCenter(tests[i, 0], tests[i, 1], tests[i, 2]); }); } }
public void CorrectlyIdentifiesDivergingScenarios() { // Sweepline at 0 for all these tests. var tests = new[,] { {new Vector(-1, 0), new Vector(1, 0), new Vector(3, 0)}, {new Vector(1, 0), new Vector(3, 1), new Vector(5, 9)}, {new Vector(1, 1), new Vector(2, 2), new Vector(3, 3)}, {new Vector(1, 1), new Vector(3, 2), new Vector(4, 7)} }; for (int i = 0; i < tests.GetLength(0); i++) Assert.That(Helpers.TestBreakpointsConvergence(tests[i, 0], tests[i, 1], tests[i, 2]), Is.False, string.Format( "Expected Helpers.TestBreakpointsConvergence() to report that the arcs defined from left to right by the sites {0}, {1}, and {2} diverged, but it reported that they converged.", tests[i, 0], tests[i, 1], tests[i, 2])); }
public void ReturnsCorrectCenter() { // First three vectors are inputs, last is expected output. var tests = new[,] { {new Vector(0, 0), new Vector(0, 10), new Vector(10, 0), new Vector(5, 5)}, {new Vector(-1,0), new Vector(0, 1), new Vector(1, 0), new Vector(0, 0)}, {new Vector(0, 10), new Vector(10, 0), new Vector(10, 30), new Vector(15, 15)} }; for (int i = 0; i < tests.GetLength(0); i++) { var output = Helpers.CircleCenter(tests[i, 0], tests[i, 1], tests[i, 2]); Assert.That(output == tests[i, 3], Is.True, string.Format("For inputs {0}, {1}, {2} expected output {3} but output was {4}.", tests[i, 0], tests[i, 1], tests[i, 2], tests[i, 3], output)); } }