Skip to content

Commit

Permalink
Unit Test added to illustrate issue appsquickly#516
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgarbarev committed Jul 8, 2016
1 parent 4d4d69b commit 3618cec
Show file tree
Hide file tree
Showing 7 changed files with 283 additions and 181 deletions.
372 changes: 192 additions & 180 deletions .idea/Typhoon.iml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,35 @@ - (id)incorrectPrototypeA
}];
}

//-------------------------------------------------------------------------------------------
#pragma mark -
//-------------------------------------------------------------------------------------------

- (id)propertyInjectionA
{
return [TyphoonDefinition withClass:[PrototypePropertyInjected class] configuration:^(TyphoonDefinition *definition) {
[definition injectProperty:@selector(propertyB) with:[self propertyInjectionB]];
[definition injectProperty:@selector(propertyC) with:[self propertyInjectionC]];
definition.autoInjectionVisibility = TyphoonAutoInjectVisibilityNone;
}];
}

- (id)propertyInjectionB
{
return [TyphoonDefinition withClass:[PrototypePropertyInjected class] configuration:^(TyphoonDefinition *definition) {
[definition injectProperty:@selector(propertyA) with:[self propertyInjectionA]];
[definition performAfterInjections:@selector(checkThatPropertyAHasPropertyBandC)];
definition.autoInjectionVisibility = TyphoonAutoInjectVisibilityNone;
}];
}

- (id)propertyInjectionC
{
return [TyphoonDefinition withClass:[PrototypePropertyInjected class] configuration:^(TyphoonDefinition *definition) {
[definition injectProperty:@selector(propertyA) with:[self propertyInjectionA]];
[definition performAfterInjections:@selector(checkThatPropertyAHasPropertyBandC)];
definition.autoInjectionVisibility = TyphoonAutoInjectVisibilityNone;
}];
}

@end
8 changes: 8 additions & 0 deletions Tests/Factory/Internal/TyphoonBlockComponentFactoryTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,14 @@ - (void)test_initializer_injected_component_is_correctly_resolved_in_circular_de
XCTAssertNotEqual(propertyInjected.prototypeInitInjected, initializerInjected);
}

//-------------------------------------------------------------------------------------------
#pragma mark - Circular dependencies with "afterInjections" hook

- (void)test_after_injections_called_after_parents_injections
{
XCTAssertNoThrow([_circularDependenciesFactory componentForKey:@"propertyInjectionA"]);
}

//-------------------------------------------------------------------------------------------
#pragma mark - Currently Resolving Overwriting Problem

Expand Down
6 changes: 6 additions & 0 deletions Tests/Model/CircularDependencies/PrototypePropertyInjected.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,10 @@

@property(nonatomic, strong) PrototypeInitInjected *prototypeInitInjected;

@property (nonatomic, strong) PrototypePropertyInjected *propertyA;
@property (nonatomic, strong) PrototypePropertyInjected *propertyB;
@property (nonatomic, strong) PrototypePropertyInjected *propertyC;

- (void)checkThatPropertyAHasPropertyBandC;

@end
15 changes: 15 additions & 0 deletions Tests/Model/CircularDependencies/PrototypePropertyInjected.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,23 @@
//
//

#import <XCTest/XCTest.h>
#import "PrototypePropertyInjected.h"

@implementation PrototypePropertyInjected


- (void)checkThatPropertyAHasPropertyBandC
{
if (!self.propertyA) {
[NSException raise:@"self.propertyA" format:@"self.propertyA is nil"];
}
if (!self.propertyA.propertyB) {
[NSException raise:@"self.propertyA.propertyB" format:@"self.propertyA.propertyB is nil"];
}
if (!self.propertyA.propertyC) {
[NSException raise:@"self.propertyA.propertyC" format:@"self.propertyA.propertyC is nil"];
}
}

@end
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10116" systemVersion="15E65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="lYN-QZ-pxc">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="lYN-QZ-pxc">
<dependencies>
<deployment version="2352" identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "9ABF21FB50867E6B13DCE6529AF3CCB1C77A9BA7",
"DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : {

},
"DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : {
"9ABF21FB50867E6B13DCE6529AF3CCB1C77A9BA7" : 0,
"45817BB3B2565CD583A7A6CD4B8797D002759C1C" : 0
},
"DVTSourceControlWorkspaceBlueprintIdentifierKey" : "96625EC7-C046-4FF3-9517-9651BEF51528",
"DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : {
"9ABF21FB50867E6B13DCE6529AF3CCB1C77A9BA7" : "Typhoon\/",
"45817BB3B2565CD583A7A6CD4B8797D002759C1C" : "Typhoon\/Source\/Vendor\/OCLogTemplate\/"
},
"DVTSourceControlWorkspaceBlueprintNameKey" : "Typhoon",
"DVTSourceControlWorkspaceBlueprintVersion" : 204,
"DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "Typhoon.xcodeproj",
"DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [
{
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/typhoon-framework\/OCLogTemplate.git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "45817BB3B2565CD583A7A6CD4B8797D002759C1C"
},
{
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "github.com:typhoon-framework\/Typhoon.git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "9ABF21FB50867E6B13DCE6529AF3CCB1C77A9BA7"
}
]
}

0 comments on commit 3618cec

Please sign in to comment.