I was introduced to Rhino Mocks via the book the Art of Unit Testing
and just starting using it a few days ago.  From the examples I read,
all of the unit tests used the Record & Replay model, the author did
mentioned that support for the Arrange, Act, and Assert model
exists.

I've been scouring the internet, reading documentation, etc to try to
find out how to go about doing this to test if a method is returning
an expected value.  Below is my code:

public interface IPilotManager {
        List<Pilot> Search(Pilot p);
        int Save(Pilot p);
    }

public class Pilot {
        public int PilotID { get; set; }
        public string FirstName { get; set; }
        public string MiddleInitial { get; set; }
        public string LastName { get; set; }
    }

And below is my unit test:

[TestMethod]
public void PilotSearch_SearchCriteriaSpecified_PilotFound() {
//This logic fails because the call to the Search method in the Assert
line doesn't return the List of Pilots
    IPilotManager pilotMngrStub = Mocks.Stub<IPilotManager>();
    pilotMngrStub.Expect(p => p.Search(null)).Return(new List<Pilot>()
{ TestPilot });
    Assert.IsTrue(pilotMngrStub.Search(null).Contains(TestPilot),
"Failed");

//This logic passes.  The call to Search returns a List of pilots in
the Search method.
    IPilotManager pilotMngrStub =
MockRepository.GenerateStub<IPilotManager>();
    pilotMngrStub.Expect(p => p.Search(null)).Return(new List<Pilot>()
{ TestPilot });
    Assert.IsTrue(pilotMngrStub.Search(null).Contains(TestPilot),
"Failed");
}

What is the difference between the two?  I thought the
MockRepository.GenerateStub was introduced as a way to reduce book
keeping (as the documentation states), but it looks like there is a
difference that I'm not picking up.

-- 
You received this message because you are subscribed to the Google Groups 
"Rhino.Mocks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rhinomocks?hl=en.

Reply via email to