public void Setter_Expectation_With_Custom_Ignore_Arguments()
        {
            IBar bar = MockRepository.Mock <IBar>();

            bar.SetUnexpectedBehavior(UnexpectedCallBehaviors.BaseOrDefault);
            bar.ExpectProperty(x => x.Foo = Arg <int> .Is.Anything);

            bar.Foo = 2;
            bar.VerifyAllExpectations();
        }
        public void Setter_Expectation_Not_Fullfilled()
        {
            IBar bar = MockRepository.Mock <IBar>();

            bar.SetUnexpectedBehavior(UnexpectedCallBehaviors.BaseOrDefault);
            bar.ExpectProperty(x => x.Foo = Arg <int> .Is.Anything);

            Assert.Throws <ExpectationViolationException>(
                () => bar.VerifyAllExpectations());
        }
        public void Setter_Expectation_With_Wrong_Argument()
        {
            IBar bar = MockRepository.Mock <IBar>();

            bar.SetUnexpectedBehavior(UnexpectedCallBehaviors.BaseOrDefault);
            bar.ExpectProperty(x => x.Foo = 1);

            bar.Foo = 0;

            Assert.Throws <ExpectationViolationException>(
                () => bar.VerifyExpectations(true));
        }
Example #4
0
        public void IgnoreArguments()
        {
            IFoo myFoo = MockRepository.Mock <IFoo>();

            myFoo.SetUnexpectedBehavior(UnexpectedCallBehaviors.BaseOrDefault);
            IBar <int> myBar = MockRepository.Mock <IBar <int> >();

            myBar.SetUnexpectedBehavior(UnexpectedCallBehaviors.BaseOrDefault);

            myFoo.Expect(x => x.RunBar(myBar))
            .IgnoreArguments()
            .Return(true);

            Example <int> myExample = new Example <int>(myFoo, myBar);
            bool          success   = myExample.ExampleMethod();

            Assert.True(success);

            myFoo.VerifyExpectations();
        }