Пример #1
0
        public void SimpleMethodUsageStub()
        {
            var      stub    = new StubExample();
            IExample example = stub;

            // setup a method by assigning a function to that method
            stub.VoidMethod = () => { };

            // you can even call the method the normal way from the stub.
            stub.VoidMethod();

            // methods that return something are setup in the same way
            stub.StructMethod = () => 7;
            var result = stub.StructMethod();

            Assert.Equal(7, result);
            Assert.Equal(7, example.StructMethod());
        }