Example #1
0
        [Test] public void DoesNotOverrideToString()
        {
            cg = new ClassGenerator(typeof(AbstractThingy), mock);
            AbstractThingy s = (AbstractThingy)cg.Generate();

            mock.SetupResult("ToString", "to string");

            Assertion.AssertEquals("xx", s.ToString());
            mock.Verify();
        }
Example #2
0
        // Limitations
        [Test] public void CannotOverrideNonVirtualFeatures()
        {
            cg = new ClassGenerator(typeof(AbstractThingy), mock);
            AbstractThingy s = (AbstractThingy)cg.Generate();

            mock.SetupResult("NonVirtualMethod", "non virtual method");
            mock.SetupResult("NonVirtualProperty", "non virtual property");

            Assertion.AssertEquals("xx", s.NonVirtualMethod());
            Assertion.AssertEquals("xx", s.NonVirtualProperty);
            mock.Verify();
        }
Example #3
0
        [Test] public void CanExtendAbstractClass()
        {
            cg = new ClassGenerator(typeof(AbstractThingy), mock);
            AbstractThingy s = (AbstractThingy)cg.Generate();

            mock.ExpectAndReturn("VirtualMethod", "hello");
            mock.ExpectAndReturn("GetHashCode", 123);
            mock.ExpectAndReturn("AbstractMethod", "fish");
            mock.ExpectAndReturn("ProtectedInternalMethod", "white");

            Assertion.AssertEquals("hello", s.VirtualMethod());
            Assertion.AssertEquals(123, s.GetHashCode());
            Assertion.AssertEquals("fish", s.AbstractMethod());
            Assertion.AssertEquals("white", s.ProtectedInternalMethod());

            mock.Verify();
        }