예제 #1
0
        public void MockStringDelegateWithParams()
        {
            StringDelegateWithParams d = MockRepository.Mock <StringDelegateWithParams>();

            d.Expect(x => x(1, "111"))
            .Return("abc");

            d.Expect(x => x(2, "222"))
            .Return("def");

            Assert.Equal("abc", d(1, "111"));
            Assert.Equal("def", d(2, "222"));
            d(3, "333");

            Assert.Throws <ExpectationViolationException>(
                () => d.VerifyExpectations(true));
        }
        public void MockStringDelegateWithParams()
        {
            StringDelegateWithParams d = MockRepository.Mock <StringDelegateWithParams>(null);

            d.SetUnexpectedBehavior(UnexpectedCallBehaviors.BaseOrDefault);

            d.Expect(x => x(Arg <int> .Is.Equal(1), Arg <string> .Is.Equal("111")))
            .Return("abc");

            d.Expect(x => x(Arg <int> .Is.Equal(2), Arg <string> .Is.Equal("222")))
            .Return("def");

            Assert.Equal("abc", d(1, "111"));
            Assert.Equal("def", d(2, "222"));

            d(3, "333");

            Assert.Throws <ExpectationViolationException>(() => d.VerifyExpectations(true));
        }