示例#1
0
        public void ShouldGetValidErrorWhenGenericTypeMismatchOccurs()
        {
            ILookupMapper <int> mapper = m_mockery.StrictMock <ILookupMapper <int> >();
            Foo <string>        retval = new Foo <string>();

            Assert.Throws <InvalidOperationException>(
                "Type 'Rhino.Mocks.Tests.FieldsProblem.Foo`1[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]' doesn't match the return type 'Rhino.Mocks.Tests.FieldsProblem.Foo`1[System.Int32]' for method 'ILookupMapper`1.FindOneFoo();'",
                () => Expect.Call <object>(mapper.FindOneFoo()).Return(retval));
        }
示例#2
0
        public void ShouldBeAbleToMockGenericMethod2()
        {
            ILookupMapper <int> mapper = m_mockery.StrictMock <ILookupMapper <int> >();
            Foo <int>           retval = new Foo <int>();

            Expect.Call(mapper.FindOneFoo()).Return(retval);
            m_mockery.ReplayAll();
            Foo <int> oneFoo = mapper.FindOneFoo();

            m_mockery.VerifyAll();
        }
示例#3
0
        public void ShouldBeAbleToMockGenericMethod()
        {
            ILookupMapper <int> mapper = m_mockery.StrictMock <ILookupMapper <int> >();
            List <Foo <int> >   retval = new List <Foo <int> >();

            retval.Add(new Foo <int>());
            Expect.Call(mapper.FindAllFoo()).Return(retval);
            m_mockery.ReplayAll();
            IList <Foo <int> > listOfFoo = mapper.FindAllFoo();

            m_mockery.VerifyAll();
        }
示例#4
0
        public void ShouldBeAbleToMockGenericMethod2()
        {
            Foo <int> retval = new Foo <int>();

            ILookupMapper <int> mapper = MockRepository.Mock <ILookupMapper <int> >();

            mapper.Expect(x => x.FindOneFoo())
            .Return(retval);

            Foo <int> oneFoo = mapper.FindOneFoo();

            mapper.VerifyExpectations(true);
        }
示例#5
0
        public void ShouldBeAbleToMockGenericMethod()
        {
            List <Foo <int> > retval = new List <Foo <int> >();

            retval.Add(new Foo <int>());

            ILookupMapper <int> mapper = MockRepository.Mock <ILookupMapper <int> >();

            mapper.Expect(x => x.FindAllFoo())
            .Return(retval);

            IList <Foo <int> > listOfFoo = mapper.FindAllFoo();

            mapper.VerifyExpectations(true);
        }