The Enqueue method is not virtual and therefore can't be mocked/stubbed by Rhino.Mocks.
What you may want to do is create a real Queue<T> and use that. After your wrapper has been tested, make sure the Queue<T> contents match based on what should have been done by the wrapper. --- Patrick Steele http://weblogs.asp.net/psteele On Tue, Feb 15, 2011 at 2:14 PM, tal_mcmahon@hotNO_BOTmail.com <[email protected]> wrote: > Hello all, I am using rhino 3.6 and have a question: > > I am trying to test an object that wraps a Queue<T>. > > I have a wrapper around the Queue.Enqueue method that I need to test. > > here is the setup Code: > > _mockRepository = new MockRepository(); > _mockMessage = (IMessage)_mockRepository.StrictMock(typeof(IMessage)); > _mockSystemQueue = > (Queue<IMessage>)_mockRepository.StrictMock(typeof(Queue<IMessage>)); > _testObject = > (MessageQueue)_mockRepository.StrictMock(typeof(MessageQueue), new > object[] { _mockSystemQueue }); > > and here is the expectation statements I have tried: > > _mockSystemQueue.Expect(q => q.Enqueue(_mockMessage)); > > and > > Expect.Call(delegate { _mockSystemQueue.Enqueue(_mockMessage); }); > > Both of these give me the same error: > > "Invalid call, the last call has been used or no call has been made > (make sure that you are calling a virtual (C#) / Overridable (VB) > method)." > > Any Ideas? > > Thanks > > Tal > > -- > 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. > > -- 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.
