Exemple #1
0
        public void NullContext()
        {
            ConstructorInfo           constructor = typeof(Dummy).GetConstructor(new Type[] { typeof(int) });
            ConstructorCreationPolicy policy      = new ConstructorCreationPolicy(constructor);

            policy.Create(null, typeof(Dummy));
        }
Exemple #2
0
        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));
        }
Exemple #3
0
        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);
        }