예제 #1
0
        public void UsingPartialMocks()
        {
            MockRepository mocks = new MockRepository();
            ProcessorBase  proc  = (ProcessorBase)mocks.PartialMock(typeof(ProcessorBase));

            Expect.Call(proc.Add(1)).Return(1);
            Expect.Call(proc.Add(1)).Return(2);

            mocks.ReplayAll();

            proc.Inc();
            Assert.Equal(1, proc.Register);
            proc.Inc();
            Assert.Equal(2, proc.Register);

            mocks.VerifyAll();
        }
예제 #2
0
        public void UsingPartialMocks()
        {
            ProcessorBase proc = MockRepository.Partial <ProcessorBase>();

            proc.Expect(x => x.Add(1))
            .Return(1);

            proc.Expect(x => x.Add(1))
            .Return(2);

            proc.Inc();
            Assert.Equal(1, proc.Register);

            proc.Inc();
            Assert.Equal(2, proc.Register);

            proc.VerifyAllExpectations();
        }
        public void UsingPartialMocks()
        {
            ProcessorBase proc = MockRepository.Partial <ProcessorBase>();

            proc.SetUnexpectedBehavior(UnexpectedCallBehaviors.BaseOrDefault);

            proc.Expect(x => x.Add(1))
            .Return(1);

            proc.Expect(x => x.Add(1))
            .Return(2);

            proc.Inc();
            Assert.Equal(1, proc.Register);

            proc.Inc();
            Assert.Equal(2, proc.Register);

            proc.VerifyAllExpectations();
        }