テストケース内にファクトリを作成しています
+ (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;
}];
}