interface IPoint
{
int X { get; }
int Y { get; }
}
static bool CoincidesWith(this IPoint self, IPoint other); // implementation unknown
我想写一个NUnit的测试验证有关的CoincidesWith
意思我的假设:使用Assert.That(而不是假设)与[Theory]是否是错误的?
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
? (The documentation seems to suggest that the latter should be used in conjunction with[Theory]
.) - 这种情况确实更适合
[Theory]
而不是[Test]
?