public void NullContext() { ConstructorInfo constructor = typeof(Dummy).GetConstructor(new Type[] { typeof(int) }); ConstructorCreationPolicy policy = new ConstructorCreationPolicy(constructor); Assert.Throws <ArgumentNullException>( delegate { policy.Create(null, 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.NotNull(result); Assert.Equal(42, result.val); }
public void NonMatchingParameterTypes() { MockBuilderContext context = new MockBuilderContext(); ConstructorInfo constructor = typeof(Dummy).GetConstructor(new Type[] { typeof(int) }); ConstructorCreationPolicy policy = new ConstructorCreationPolicy(constructor, Params("foo")); Assert.Throws <ArgumentException>( delegate { policy.Create(context, typeof(Dummy)); }); }