Unfortunately, OriginalSource is not virtual so you can't mock it with Rhino.Mocks.
--- Patrick Steele http://weblogs.asp.net/psteele On Tue, Sep 16, 2014 at 8:45 AM, Vamsi Nudurupati <[email protected]> wrote: > Hi, > > I am trying to Mock the OriginalSource in the RoutedEventArgs using Rhino > Mocks. Can any one please suggest on how to make this test pass as the > OriginalSource is null so the test fails as its not able to Convert the > EventArgs to ViewModel? > > [Test] > public void Covert_ShouldReturnViewModel_WhenArgsIsPassed() > { > > var routedEventArgs = > MockRepository.GenerateStub<RoutedEventArgs>(); > var mockOriginalSource = routedEventArgs.Expect(eArgs => > eArgs.OriginalSource).Return("test mock"); > > var ViewModel = MockRepository.GenerateStub<ViewModel>(); > > var eventArgsConverterHelper = > MockRepository.GenerateMock<EventArgsConverterHelper>(); > eventArgsConverterHelper.Stub( > eArgs => > eArgs.GetCallReasonViewModelMethod(mockOriginalSource)) > .Return(callReasonViewModel) > .Repeat.Once(); > > var dTEventArgs = new EventArgsConverter(); > > Assert.That(dTEventArgs.Convert(routedEventArgs), > Is.EqualTo(ViewModel)); > } > > thanks, > Vamsi > > -- > You received this message because you are subscribed to the Google Groups > "Rhino.Mocks" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/rhinomocks. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Rhino.Mocks" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/rhinomocks. For more options, visit https://groups.google.com/d/optout.
