[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(); }
// 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(); }
[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(); }