Creating Instances of Types with Private Constructors
When to Use
When you need to instantiate a type that does not have a public constructor. Typemock Isolator creates the object from the specified type using the provided argument list and matches the correct constructor.
Syntax
C# var obj = Isolate.NonPublic.CreateInstance<type>(<list of arguments>);
VB Not supported.
Sample
C# [TestMethod] public void CreateInstanceWithAPrivateConstructor() { ClassWithNoPublicConstructor obj = Isolate.NonPublic.CreateInstance<ClassWithNoPublicConstructor>(1, 2); Assert.AreEqual(obj.x, 1); Assert.AreEqual(obj.y, 2); }
VB Not supported.