/// <summary>
///A test for ReverseName
///</summary>
[TestMethod()]
public void ReverseNameTest()
{
Mock<IEntityName> entityName = new Mock<IEntityName>();
entityName.SetupProperty(x => x.FirstName, "John");
entityName.SetupProperty(x => x.LastName, "T.");
var p = new Person(entityName.Object);
string expected = "Your reverse name is T. John";
string actual;
actual = p.ReverseName();
Assert.AreEqual(expected, actual);
}
}
//人物类
public Person(IEntityName EntityName)
{
this.EntityName = EntityName;
}
是否可以在 TestMehod 中模拟 Person 类,或者我是否必须像上面那样创建 Person 的实例?