Hi,

I tried removing the second Expect Call.. and infact the error I got
was almost the same...

 [TestFixture]
    public class RihoMock35Problem
    {
        private MockRepository _mockRepo;
        private Exception _lastException;
        private IList<int> _list;
        [Test]
        public void RhinoMock35ProblemTest()
        {
            _mockRepo = new MockRepository();
            CreateMock();

            _lastException = null;

            Thread t = new Thread(CreateMock);
            t.Start();
            t.Join();
            Assert.IsNull(_lastException);
        }

        public void CreateMock()
        {
            try
            {
                if (_list == null)
                {
                    _list = _mockRepo.DynamicMock<IList<int>>();
                }
                _mockRepo.BackToRecordAll();
                Expect.Call(_list.Count).Return(5);
                _mockRepo.ReplayAll();
                Assert.AreEqual(5, _list.Count);
            }
            catch (Exception e)
            {

                _lastException = e;
            }
        }
    }

I am keep on getting the errror of Null Reference...

On Aug 6, 12:55 am, Kenneth Xu <[email protected]> wrote:
> After I added back to record and replay, your test cases passed fine for me.
>
>                 Assert.AreEqual(5, list.Count);
>                 _mockRepo.BackToRecordAll();
>
>                 Expect.Call(list.Count).Return(50);
>                 _mockRepo.ReplayAll();
>                 Assert.AreEqual(50, list.Count);
>
> Without those, it actually failed at your first CreateMock call. Try
> to first verify the method works fine in current thread:
>
>         public void RhinoMock35ProblemTest()
>         {
>             _mockRepo = new MockRepository();
>
>             _lastException = null;
>             CreateMock();
>             Assert.IsNull(_lastException, "Bad CreateMock by
> itself!"); // failed here with your original CreateMock.
>
>             _lastException = null;
>             Thread t = new Thread(CreateMock);
>             t.Start();
>             t.Join();
>             Assert.IsNull(_lastException, "Bad CreateMock in new Thread.");
>         }
>
>
>
> On Wed, Aug 5, 2009 at 11:05 AM, Vikash Mitruka<[email protected]> wrote:
> > No that is not causing the issue.. the issue seems to be related to
> > multi threading in Rhino 3.5.
--~--~---------~--~----~------------~-------~--~----~
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