Esempio n. 1
0
        public void MockClassExpectException()
        {
            RemotableDemoClass demo = MockRepository.Mock <RemotableDemoClass>();

            demo.Expect(x => x.Two())
            .Throws <InvalidOperationException>();

            Assert.Throws <InvalidOperationException>(
                () => contextSwitcher.DoStuff(demo));
        }
Esempio n. 2
0
        public void MockClass()
        {
            RemotableDemoClass demo = MockRepository.Mock <RemotableDemoClass>();

            demo.Expect(x => x.Two())
            .Return(44);

            Assert.Equal(44, contextSwitcher.DoStuff(demo));
            demo.VerifyAllExpectations();
        }
Esempio n. 3
0
        public void MockClassExpectException()
        {
            RemotableDemoClass demo = MockRepository.Mock <RemotableDemoClass>();

            demo.SetUnexpectedBehavior(UnexpectedCallBehaviors.BaseOrDefault);

            demo.Expect(x => x.Two())
            .Throws <InvalidOperationException>();

            Assert.Throws <InvalidOperationException>(
                () => contextSwitcher.DoStuff(demo));
        }
Esempio n. 4
0
        public void MockClass()
        {
            RemotableDemoClass demo = MockRepository.Mock <RemotableDemoClass>();

            demo.SetUnexpectedBehavior(UnexpectedCallBehaviors.BaseOrDefault);

            demo.Expect(x => x.Two())
            .Return(44);

            Assert.Equal(44, contextSwitcher.DoStuff(demo));
            demo.VerifyAllExpectations();
        }
Esempio n. 5
0
        public void MockClassUnexpectedCall()
        {
            RemotableDemoClass demo = MockRepository.Mock <RemotableDemoClass>();

            demo.Expect(x => x.Prop)
            .Return(11);

            contextSwitcher.DoStuff(demo);

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