使用 Josh Flanagans StructureMap Automocking overview,我正在尝试它,但可以获得以下代码来返回我分配的 Category 对象:
[Test]
public void Service_Should_Return_Category_From_ID()
{
// Arrange
var categoryToTest = new Category()
{
ID = 1,
Name = "Department 1",
Description = "Department 1 description"
};
var mocks = new RhinoAutoMocker<CatalogueService>();
mocks.Get<ICatalogueService>().Stub(c => c.GetCategory(1)).Return(categoryToTest);
// Act
var categoryResult = mocks.ClassUnderTest.GetCategory(1);
// Assert
Assert.IsNotNull(categoryResult);
Assert.AreEqual(categoryToTest.ID, categoryResult.ID);
}
我究竟做错了什么?