Function stubbed with Structuremap Automocking returns no value

Using Josh Flanagans StructureMap Automocking overview , I am trying to use it but can get the following code to return the Category object I 'assigned:

    [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);
    }

      

What am I doing wrong?

0


a source to share


1 answer


I was adding the return value to the interface of the class under test, not the nested interface.



0


a source







All Articles