Skip to content

Instantly share code, notes, and snippets.

@SimonCropp
Created April 19, 2012 09:36
Show Gist options
  • Select an option

  • Save SimonCropp/2419965 to your computer and use it in GitHub Desktop.

Select an option

Save SimonCropp/2419965 to your computer and use it in GitHub Desktop.
Bypass Protected Constructor 2
public class BaseClass
{
protected BaseClass()
{
}
}
[TestFixture]
public class Foo2
{
[Test]
public void Bar()
{
BaseClass instance = (BaseClass) FormatterServices.GetUninitializedObject(typeof (BaseClass));
Assert.IsNotNull(instance);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment