views:

137

answers:

1

Using Josh Flanagans StructureMap Automocking overview, I'm trying my hand at it but can get the following code to return the Category object I've 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?

A: 

I was adding the return value to the Interface of the class under test, not the Interface that was being Injected.

I Clark