Hmm I don't see why you need to generate *all* mocks - if you're
mocking that *particular* chain only, you can use recursive mocks, as
I posted above.

If that example doesn't work for you, maybe you're using an old
version of RM (as far as I remember, 3.5 does not support recursive
mocks).

I'm using 3.5.0.1337 compiled from sources (revision #1928), this one
works fine.




On Feb 11, 1:59 pm, BFreakout <[email protected]> wrote:
> This is the Interface from VSTO Document... (Word 2003)
>
> i have change to:
>
>             Range range = MockRepository.GenerateMock<Range>();
>             Document document = MockRepository.GenerateMock<Document>
> ();
>             Tables tables = MockRepository.GenerateMock<Tables>();
>             Cell cell = MockRepository.GenerateMock<Cell>();
>
>             range.Expect(x => x.Text).Return("Hello World");
>             cell.Expect(x => x.Range).Return(range);
>             tables.Expect(x => x[1].Cell(1, 1)).Return(cell);
>             document.Expect(x => x.Content.Tables).Return(tables);
>
>             Assert.AreEqual("Hello World", document.Content.Tables
> [1].Cell(1,1).Range.Text);
>
> Here is Exception to:
>
> TestMockTest.TestMethod : FailedSystem.NullReferenceException: Der
> Objektverweis wurde nicht auf eine Objektinstanz festgelegt.
> bei TestMockTest.<TestMethod>b__2(Tables x) in TestMock.cs: line 21.
> bei Rhino.Mocks.RhinoMocksExtensions.Expect<T,R>(T mock, Function`2
> action)
> bei TestMethod() in TestMock.cs: line 21.
>
> On Feb 11, 1:31 pm, andreister <[email protected]> wrote:
>
> >         [Test]
> >         public void TestMe()
> >         {
> >             var document = MockRepository.GenerateMock<IDocument>();
> >             var table = MockRepository.GenerateMock<Table>();
>
> >             table.Expect(x => x.Cell(1, 1).Range.Text).Return("Hello
> > World");
> >             document.Expect(x => x.Content.Tables).Return(new[]
> > { null, table });
>
> >             Assert.AreEqual("Hello World", document.Content.Tables
> > [1].Cell(1, 1).Range.Text);
> >         }
>
> > On Feb 11, 9:33 am, BFreakout <[email protected]> wrote:
>
> > > he...@all,
>
> > > my Problem is the System.NullReferenceException with Mock from my
> > > Interface... here the Example this doesn't work:
>
> > > using NUnit.Framework;
> > > using Rhino.Mocks;
> > > using TuevExportConverter.Infrastructure.Contracts;
>
> > > namespace TuevExportConverter.BDD
> > > {
> > >     [TestFixture]
> > >     public class TestMockTest
> > >     {
> > >         [Test]
> > >         public void TestMethod()
> > >         {
> > >             IDocument document = MockRepository.GenerateMock<IDocument>
> > > ();
> > >             document.Stub(x => x.Content.Tables[1].Cell(1,
> > > 1).Range.Text).Return("Hello World");
>
> > >             Assert.AreEqual("Hello World", document.Content.Tables
> > > [1].Cell(1, 1).Range.Text);
> > >         }
> > >     }
>
> > > }
>
> > > what can i do, for this Mock -> Tables[1].Cell(1, 1)
>
> > > regards,
>
> > > BFreakout- Hide quoted text -
>
> > - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
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