Hi.

In the following  code the object return the right object only in test
method but not in the testes method.
Is that normal behavior?
If yes what should I do to test that method?
Create my own mock object?

the code:
 class Program
    {
        static void Main(string[] args)
        {

        }

        public IDemo demo;
        public  void inner()
        {
            var x = demo.lst;

            //exception x= null
            var y = x[0];
        }
    }
    [TestFixture]
    public class Class1
    {
        [Test]
        public void ts()
        {
            MockRepository mock = new MockRepository();
            var c = mock.Stub<IDemo>();
            //Workin
            Expect.Call(c.lst).Return(new List<int>() { 0 });
            Program p = new Program();
            p.demo = c;

            ////Faild with System.NullReferenceException on the lst.
            //Expect.Call(c.lst[0]).Return(0);

            mock.ReplayAll();
            var v = c.lst;
            Assert.That(v, Is.Not.Null);
            // pass  no problem
            Assert.That(v[0], Is.EqualTo(0));
            p.inner();
        }
    }

    public interface IDemo
    {
        List<int> lst { get; }

    }

thank Adiel

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