Example #1
0
        public void DefaultTypeCtor_Uses_Default_Ctor_If_Available()
        {
            var convention = new DefaultComplexTypeCtorConvention();
            var context    = new Mock <ITypeConventionContext>();

            context.SetupGet(x => x.Target).Returns(typeof(SampleDefaultCtorType));
            convention.Apply(context.Object);

            context.Verify(x => x.SetFactory(
                               It.Is <Type>(type => type == typeof(CtorSource <SampleDefaultCtorType>)),
                               typeof(SampleDefaultCtorType).GetConstructor(Type.EmptyTypes)), Times.Once());
        }
Example #2
0
        public void DefaultTypeCtor_Seeks_Least_Greedy_Ctor()
        {
            var convention = new DefaultComplexTypeCtorConvention();
            var context    = new Mock <ITypeConventionContext>();

            context.SetupGet(x => x.Target).Returns(typeof(SampleCtorType));
            convention.Apply(context.Object);

            context.Verify(x => x.SetFactory(
                               It.Is <Type>(type => type == typeof(CtorSource <SampleCtorType>)),
                               typeof(SampleCtorType).GetConstructor(new[] { typeof(int) })), Times.Once());
        }