我正在测试用例中创建工厂
+ (TyphoonComponentFactory*)integrationTestFactory
{
static TyphoonComponentFactory* factory;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^
{
factory = [[TyphoonBlockComponentFactory alloc] initWithAssemblies:@[
[MainAssembly assembly],
[Kernel assembly],
[NetworkComponents assembly],
[PersistenceComponents assembly]
]];
//Other config here. . .
TyphoonConfigPostProcessor *configurer = [TyphoonConfigPostProcessor configurer];
[configurer useResourceWithName:@"testConfig.properties"];
[factory attachPostProcessor:configurer];
//this may be necessary
[factory makeDefault
});
return factory;
}
然后访问它
- (void)setUp
{
[super setUp];
factory_instance = [LoginTest integrationTestFactory];
}
最后访问程序集给出了配置键未配置的错误值
DAO *dataManager = [(DaoAssembly*)factory_instance DAO];
组装如下
-(id)DAO {
return [TyphoonDefinition withClass:[DAO class] configuration:^(TyphoonDefinition* definition)
{
[definition useInitializer:@selector(shareManager)];
[definition injectProperty:@selector(apikey) with:TyphoonConfig(@"api.key")];
[definition injectProperty:@selector(dataParser) with:[self dataParser]];
definition.scope = TyphoonScopeSingleton;
}];
}