You're mixing record/replay (new MockRepository()) and AAA modes.

On Wed, Nov 4, 2009 at 11:53 AM, kbaltrinic <[email protected]> wrote:

>
> I just started to use the new AAA approach with a new project that I
> am on and spent some time distilling down why my first AAA unit tests
> was failing.  It appears that something is wrong with the Stub()
> method when used on a instance of MockRepository (as opposed to the
> static MockRepository.GenerateStub()).  Is this just me or can others
> reproduce the following results (Rhino 3.6 and NUnit 2.5.2)
>
>        public interface ITest { int GetInt(); }
>
>        [Test]
>        public void this_test_fails()
>        {
>            var repositoryIntance = new MockRepository();
>
>            var test= repositoryIntance.Stub<ITest>();
>            test.Stub(t => t.GetInt()).Return(1);
>
>            var id = test.GetInt();
>            Assert.That(id, Is.EqualTo(1));  //Fails id is 0!
>        }
>
>        [Test]
>        public void this_test_passes()
>        {
>            var test= MockRepository.GenerateStub<ITest>();
>            test.Stub(s => s.GetInt()).Return(1);
>
>            var id = test.GetInt();
>            Assert.That(id, Is.EqualTo(1));
>        }
>
>
> --Ken
>
> >
>


-- 
Tim Barcz
Microsoft C# MVP
Microsoft ASPInsider
http://timbarcz.devlicio.us
http://www.twitter.com/timbarcz

--~--~---------~--~----~------------~-------~--~----~
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