我正在使用Visual Studio 2012,遇到了以下错误:"Error 'hw02.World' does not contain a constructor that takes 2 arguments." 我想为我的类创建单元测试:
class World : IWorld
{
public World(int width, int height)
{
Width = width;
Height = height;
world = new IBuilding[width, height];
}
}
出现错误的测试:
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
var world = new World(5, 5); // this line creates the error: 'hw02.World' does not contain a constructor that takes 2 arguments
}
}
感谢您的帮助。
World
类吗?你的第一个类肯定是hw02.World
吗? - Jon Skeet