0

使用 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);
    }

我究竟做错了什么?

4

1 回答 1

0

我将返回值添加到被测类的接口,而不是被注入的接口。

于 2009-05-19T06:15:58.107 回答