【发布时间】:2014-06-25 05:00:16
【问题描述】:
使用 Nunit 或 Microsoft.VisualStudio.TestTools.UnitTesting。现在我的断言失败了。
[TestMethod]
public void GivenEmptyBoardExpectEmptyBoard()
{
var test = new Board();
var input = new Board()
{
Rows = new List<Row>()
{
new Row(){Cells = new List<int>(){0,0,0,0}},
new Row(){Cells = new List<int>(){0,0,0,0}},
new Row(){Cells = new List<int>(){0,0,0,0}},
new Row(){Cells = new List<int>(){0,0,0,0}},
}
};
var expected = new Board()
{
Rows = new List<Row>()
{
new Row(){Cells = new List<int>(){0,0,0,0}},
new Row(){Cells = new List<int>(){0,0,0,0}},
new Row(){Cells = new List<int>(){0,0,0,0}},
new Row(){Cells = new List<int>(){0,0,0,0}},
}
};
var lifeOrchestration = new LifeOrchestration();
var actual = lifeOrchestration.Evolve(input);
Assert.AreEqual(expected, actual);
}
【问题讨论】:
-
在每个对象中覆盖 .Equals 和 .GetHashCode,对于集合,请查看 *.com/questions/19861619/nunit-comparing-two-lists
标签: c# .net unit-testing tdd nunit