コード例 #1
0
        public void CanCallOverloadConstructor()
        {
            var          stub    = new StubExampleClass(3);
            ExampleClass example = stub;

            Assert.Equal(3, example.CallsToMethod);
        }
コード例 #2
0
        public void ProtectedFieldUsage()
        {
            var stub = new StubExampleClass();

            stub.sampleField = 7;

            Assert.Equal(7, stub.sampleField);
        }
コード例 #3
0
        public void ProtectedMethodUsage()
        {
            var          stub    = new StubExampleClass();
            ExampleClass example = stub;

            stub.MethodToCall2();

            Assert.Equal(1, example.CallsToMethod);
        }
コード例 #4
0
        public void CanCallConstructorWithSubclassParameters()
        {
            var stub1 = new StubExampleClass("bob");

            StubExampleClass stub2;

            using (StubExampleClass.DeferConstruction("tommy", out stub2)) { }

            ExampleClass example = stub1;

            Assert.Equal(3, example.CallsToMethod); // length of 'bob'

            example = stub2;
            Assert.Equal(5, example.CallsToMethod); // length of 'tommy'
        }