public void CreateDefaultConstructorTest()
        {
            var defaultConstructor    = ExpressionUtils.CreateDefaultConstructor <SampleClass>();
            var setterIntegerProperty = ExpressionUtils.CreateSetter <SampleClass, int>(x => x.IntegerProperty);

            var sampleEntity = defaultConstructor();

            setterIntegerProperty(sampleEntity, 1);

            Assert.AreEqual(1, sampleEntity.IntegerProperty);
        }
Пример #2
0
 private IProductScope NewProduct(ProductType productType)
 {
     if (_productConstructors == null)
     {
         _productConstructors = ProductType
                                .GetAll <ProductType>()
                                .Select(pt => new
         {
             ProductType = pt,
             Constructor = ExpressionUtils.CreateDefaultConstructor <IProductScope>(pt.Type)
         })
                                .ToDictionary(x => x.ProductType, x => x.Constructor);
     }
     return(_productConstructors[productType]());
 }