Created
April 19, 2012 09:36
-
-
Save SimonCropp/2419965 to your computer and use it in GitHub Desktop.
Bypass Protected Constructor 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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