Search code examples
c#mockingrhino-mocks

How to save arguments of function call in Rhino Mocks?


    MockRepository mocks = new Rhino.Mocks.MockRepository();  
    IActiveProgram  repository = mocks.CreateMock<IActiveProgram>();  


    var readPrg = new ReadProgram();
    readPrg.init("333", "eee", "", null, repository);

In readPrg.init I will have a several calls on repository object. For example repository.AddProgram(programName);

How I will be able to know later on exit from readPrg.init to know the arguments that my prerecorded function calls been executed.

Thanks for help.


Solution

  • You'd call repository.AssertWasCalled(x => x.AddProgram(programName)) after you call init. Look also in the original post of Rhino Mocks AAA syntax
    Another option, you could use Expect:

    repository.Expect(x => x.AddProgram(programName)).Repeat.Times(50)
    var readPrg = new ReadProgram();
    readPrg.init("333", "eee", "", null, repository);
    repository.VerifyAllExpectations()