public void NullContext() { ConstructorInfo constructor = typeof(Dummy).GetConstructor(new Type[] { typeof(int) }); ConstructorCreationPolicy policy = new ConstructorCreationPolicy(constructor); policy.Create(null, typeof(Dummy)); }
public void NonMatchingParameterTypes() { MockBuilderContext context = new MockBuilderContext(); ConstructorInfo constructor = typeof(Dummy).GetConstructor(new Type[] { typeof(int) }); ConstructorCreationPolicy policy = new ConstructorCreationPolicy(constructor, Params("foo")); policy.Create(context, typeof(Dummy)); }
public void CreatesObjectAndPassesValue() { MockBuilderContext context = new MockBuilderContext(); ConstructorInfo constructor = typeof(Dummy).GetConstructor(new Type[] { typeof(int) }); ConstructorCreationPolicy policy = new ConstructorCreationPolicy(constructor, Params(42)); Dummy result = (Dummy)policy.Create(context, typeof(Dummy)); Assert.IsNotNull(result); Assert.AreEqual(42, result.val); }