예제 #1
0
        public void UseTheOutMethodToSpecifyOutputAndRefParameters_CanOnlyBeCalledOnce()
        {
            MockRepository mocks   = new MockRepository();
            MyClass        myClass = (MyClass)mocks.StrictMock(typeof(MyClass));
            int            i;
            string         s = null, s2;

            myClass.MyMethod(out i, ref s, 1, out s2);
            Assert.Throws <InvalidOperationException>(
                "Output and ref parameters has already been set for this expectation",
                () => LastCall.OutRef(100, "s", "b").OutRef(100, "s", "b"));
        }
        public void GenericMethodWithOutDecimalParameter()
        {
            MockRepository mocks = new MockRepository();
            IMyInterface   mock  = mocks.StrictMock <IMyInterface>();

            decimal expectedOutParameter = 1.234M;

            using (mocks.Record())
            {
                decimal emptyOutParameter;
                mock.GenericMethod(out emptyOutParameter);
                LastCall.OutRef(expectedOutParameter);
            }

            using (mocks.Playback())
            {
                decimal outParameter;
                mock.GenericMethod(out outParameter);
                Assert.Equal(expectedOutParameter, outParameter);
            }
        }