interface IPoint
{
int X { get; }
int Y { get; }
}
static bool CoincidesWith(this IPoint self, IPoint other); // implementation unknown
我想编写一个 NUnit 测试来验证我对以下含义的假设CoincidesWith
:
self.CoincidesWith(other)
⇔ (self.X
=other.X
) ∧ (self.Y
=other.Y
)
以下是迄今为止我能想到的最简洁的测试:
[Theory]
void CoincidesWith_Iff_CoordinatesAreEqual(IPoint self, IPoint other)
{
bool coordinatesAreEqual = (self.X == other.X && self.Y == other.Y);
Assert.That(self.CoincidesWith(other) == coordinatesAreEqual);
}
我的问题,按重要性降序排列,是:
- 用,代替?
[Theory]
被认为是错误的或不好的风格?(文档似乎建议后者应与 . 一起使用。)Assert.That
Assume.That
[Theory]
- 这种情况确实更适合 a
[Theory]
而不是 a[Test]
吗?