NUnit Test Runner和Visual Studio NUnit Test运行器为测试获得不同的结果

时间:2015-04-21 15:25:45

标签: visual-studio unit-testing nunit

the geometry library I am writing中,当我在Visual Studio中使用NUnit测试运行器运行时,我有一个奇怪的测试,但是当它在常规NUnit运行器上运行时,它会失败。我正在测试相同的DLL

以下是测试:

    [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);
    }

似乎sort函数在两种情况下的工作方式不同。导致测试在NUnit运行器中失败,其中列表顺序不等于预期值。

enter image description here

enter image description here

是什么导致这个?我该如何解决?我们的构建服务器与NUnit runner

的行为相同

0 个答案:

没有答案