Skip to content

Instantly share code, notes, and snippets.

@scottwater
Created December 7, 2010 18:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottwater/732163 to your computer and use it in GitHub Desktop.
Save scottwater/732163 to your computer and use it in GitHub Desktop.
public class BaseClass
{
public string STRING { get { return "Base"; } }
}
public class ChildClass : BaseClass
{
public new string STRING { get { return "Child"; } }
}
[TestFixture]
public class tests
{
[Test]
public void NOT_WHAT_YOU_THOUGHT()
{
BaseClass bc = new ChildClass();
Assert.That(bc.STRING == "Base");
}
[Test]
public void STILL_NOT_WHAT_YOU_THOUGHT()
{
BaseClass bc = new ChildClass();
ChildClass cc = bc as ChildClass;
Assert.IsNotNull(cc);
Assert.That(cc.STRING == "Child");
}
[Test]
public void WTF()
{
Assert.That(test_method(new ChildClass()) == "Base");
}
string test_method(BaseClass baseClass)
{
return baseClass.STRING;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment