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]
?