[InternalsVisibileTo(RhinoMocks.StrongName)]

On Tue, Nov 18, 2008 at 12:31 PM, rod <[EMAIL PROTECTED]> wrote:

>
> Hi
> I'm using internal methods in my classes and I've noticed that
> PartialMock doesn't handle them correctly.
>
> Here we have a simple test:
>
>
> using System;
> using Rhino.Mocks;
> using NUnit.Framework;
>
> namespace UnitTests
> {
>        [TestFixture]
>        public class RhinoMockTests
>        {
>                public MockRepository Mockery;
>
>                [SetUp]
>                public void SetUp()
>                {
>                        Mockery = new MockRepository();
>                }
>
>                [Test]
>                public void
> SetResult_WithOne_DoDeletateWithTwoAndResultIsTwo()
>                {
>                        SimpleClass sut =
> Mockery.PartialMock<SimpleClass>();
>
>                        using (Mockery.Record())
>                        {
>                                Expect.Call(delegate { sut.SetResult("1");
> })
>                                        .IgnoreArguments()
>                                        .Do((Action<string>) delegate{
> sut.Result = "2"; })
>                                        .Repeat.Once();
>                        }
>
>                        using (Mockery.Playback())
>                        {
>                                sut.SetResult("1");
>                                Assert.AreEqual("2", sut.Result);
>                        }
>                }
>        }
>
>        public class SimpleClass
>        {
>                public string Result;
>
>                internal virtual void SetResult(string txt)
>                {
>                        Result = txt;
>                        throw new Exception("I shouldn't be called");
>                }
>        }
> }
>
> In this test we will get  Exception("I shouldn't be called"), but if
> we made SetResult as public not virtual then test will pass.
>
> Greetings
> rod
>
> >
>

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