private IObjectBuilder CreateBuilderForType(Type searchType)
 {
     EnsureTypeExists(searchType);
     IEngineConfigurationType type = mConfiguration.GetRegisteredType(searchType);
     var builder = new ObjectBuilder(type);
     mObjectBuilders.Add(builder);
     return builder;
 }
Пример #2
0
        public void TestSetup()
        {
            Mock<IEngineConfigurationType> type = new Mock<IEngineConfigurationType>();
            type.SetupGet(x => x.RegisteredType).Returns(typeof(SimpleUser));
            ObjectBuilder builder = new ObjectBuilder(type.Object);
            builder.AddAction(
                new ObjectPropertySetFromSourceAction(
                    ReflectionHelper.GetMember<SimpleUser>(x=>x.FirstName) as EngineTypePropertyMember,
                    new SimpleDataSource(mTestPropertyValue)
                    ));
            builder.AddAction(
                new ObjectPropertySetFromSourceAction(
                    ReflectionHelper.GetMember<SimpleUser>(x => x.LastName) as EngineTypePropertyMember,
                    new SimpleDataSource(mTestPropertyValue)
                    ));
            builder.AddAction(
                new ObjectPropertySetFromSourceAction(
                    ReflectionHelper.GetMember<SimpleUser>(x => x.EmailAddress) as EngineTypePropertyMember,
                    new SimpleDataSource(mTestPropertyValue)
                    ));

            Mock<IGenerationConfiguration> builderRepository = new Mock<IGenerationConfiguration>();
            builderRepository.Setup(x=>x.GetBuilderForType(typeof(SimpleUser))).Returns(builder);
            builderRepository.SetupGet(x => x.RecursionLimit).Returns(10);

            mGenerationContext = new GenerationContext(builderRepository.Object);
            mMethodGenerator = new ObjectGenerator<SimpleMethodClass>(
                mGenerationContext, builder);

            mUserGenerator = new ObjectGenerator<SimpleUser>(mGenerationContext, builder);
        }