Beispiel #1
0
        public void OutAndRefMethodUsage()
        {
            var      stub    = new StubExample();
            IExample example = stub;

            // IExample has an out method named "OutMethod(int, out int)"
            // in the stub, methods with out or ref parameters are exposed using the method name suffixed with the parameter types.
            // also, lambas using out/ref parameters require full types specificied for the parameters.
            stub.OutMethod_int_int = (int input, out int output) => { output = input + 2; };

            int number;

            example.OutMethod(5, out number);
            Assert.Equal(7, number);

            // ref params work the same way.
            stub.RefMethod_int_string = (int input, ref string reference) => true;
        }