5

In the geometry library I am writing I have a strange test that passes when I run using the NUnit test runner in Visual Studio, but when it runs on the regular NUnit runner it fails. I am testing the same DLLs

Here is the test:

    [Test()]
    public void Line_Sort()
    {
        Line line1 = new Line(PointGenerator.MakePointWithInches(3, 2, 5), PointGenerator.MakePointWithInches(5, 3, 7)); //intersects at -1, 0, 1
        Line line2 = new Line(PointGenerator.MakePointWithInches(6, 0, 0), PointGenerator.MakePointWithInches(-5, 3, -1)); //intersects at 6, 0, 0
        Line line3 = new Line(PointGenerator.MakePointWithInches(1, 1, 5), PointGenerator.MakePointWithInches(2, 2, 4)); //intersects at 0, 0, 6
        Line line4 = new Line(PointGenerator.MakePointWithInches(4, 10, 1), PointGenerator.MakePointWithInches(4, 5, 2)); //intersects at 4, 0, 3
        Line line5 = new Line(PointGenerator.MakePointWithInches(4, 2, 2), PointGenerator.MakePointWithInches(4, 2, 1)); //doesnt intersect

        List<Line> lines = new List<Line> { line2, line3, line5, line4, line1 };

        lines.Sort();

        lines[0].Should().Be(line1);
        lines[1].Should().Be(line3);
        lines[2].Should().Be(line4);
        lines[3].Should().Be(line2);
        lines[4].Should().Be(line5);
    }

It seems that the sort function works differently in the two cases. Causing the test to fail in the NUnit runner where the list order is not equal to the expected.

enter image description here

enter image description here

What could cause this? And how can I fix it? Our build server behaves the same as the NUnit runner

jth41
  • 3,808
  • 9
  • 59
  • 109

0 Answers0