ソースを参照

add container store in order to support push

Ran Greenberg 7 年 前
コミット
454bc30dac

+ 2
- 0
ios/RNN.h ファイルの表示

@@ -4,12 +4,14 @@
4 4
 
5 5
 #import "RNNEventEmitter.h"
6 6
 #import "RCTBridge.h"
7
+#import "RNNStore.h"
7 8
 
8 9
 @interface RNN : NSObject
9 10
 
10 11
 @property (readonly) BOOL isReadyToReceiveCommands;
11 12
 @property (readonly) RCTBridge* bridge;
12 13
 @property (readonly) RNNEventEmitter* eventEmitter;
14
+@property (readonly) RNNStore *store;
13 15
 
14 16
 +(instancetype)instance;
15 17
 

+ 12
- 0
ios/RNN.m ファイルの表示

@@ -11,12 +11,16 @@
11 11
 @property (readwrite) BOOL isReadyToReceiveCommands;
12 12
 @property (readwrite) RNNEventEmitter* eventEmitter;
13 13
 
14
+@property (readwrite) RNNStore *store;
15
+
14 16
 @end
15 17
 
16 18
 @implementation RNN
17 19
 
20
+
18 21
 # pragma mark public
19 22
 
23
+
20 24
 +(instancetype)instance
21 25
 {
22 26
 	static RNN *sharedInstance = nil;
@@ -31,10 +35,13 @@
31 35
 	return sharedInstance;
32 36
 }
33 37
 
38
+
34 39
 -(void)bootstrap:(NSURL *)jsCodeLocation launchOptions:(NSDictionary *)launchOptions
35 40
 {
36 41
 	self.eventEmitter = [RNNEventEmitter new];
37 42
 	
43
+	self.store = [RNNStore new];
44
+	
38 45
 	UIApplication.sharedApplication.delegate.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
39 46
 	UIApplication.sharedApplication.delegate.window.backgroundColor = [UIColor whiteColor];
40 47
 	
@@ -45,8 +52,10 @@
45 52
 	self.bridge = [[RCTBridge alloc] initWithBundleURL:jsCodeLocation moduleProvider:nil launchOptions:launchOptions];
46 53
 }
47 54
 
55
+
48 56
 # pragma mark private
49 57
 
58
+
50 59
 -(void)registerForJsEvents
51 60
 {
52 61
 	[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onJavaScriptLoaded) name:RCTJavaScriptDidLoadNotification object:self.bridge];
@@ -57,15 +66,18 @@
57 66
 #pragma GCC diagnostic pop
58 67
 }
59 68
 
69
+
60 70
 -(void)onJavaScriptLoaded
61 71
 {
62 72
 	self.isReadyToReceiveCommands = true;
63 73
 	[self.eventEmitter sendOnAppLaunched];
64 74
 }
65 75
 
76
+
66 77
 -(void)onJavaScriptDevReload
67 78
 {
68 79
 	UIApplication.sharedApplication.delegate.window.rootViewController = nil;
69 80
 }
70 81
 
82
+
71 83
 @end

+ 7
- 3
ios/RNNBridgeModule.m ファイルの表示

@@ -3,6 +3,7 @@
3 3
 #import "RNN.h"
4 4
 #import "RNNControllerFactory.h"
5 5
 #import "RNNReactRootViewCreator.h"
6
+#import "RNNStore.h"
6 7
 
7 8
 @implementation RNNBridgeModule
8 9
 
@@ -16,8 +17,9 @@ RCT_EXPORT_MODULE();
16 17
 RCT_EXPORT_METHOD(setRoot:(NSDictionary*)layout)
17 18
 {
18 19
 	[self assertReady];
19
-	RNNControllerFactory *factory = [[RNNControllerFactory alloc] initWithRootViewCreator:[RNNReactRootViewCreator new]];
20
+	RNNControllerFactory *factory = [[RNNControllerFactory alloc] initWithRootViewCreator:[RNNReactRootViewCreator new] store:[RNN instance].store];
20 21
 	UIViewController *vc = [factory createLayout:layout];
22
+	
21 23
 	UIApplication.sharedApplication.delegate.window.rootViewController = vc;
22 24
 	[UIApplication.sharedApplication.delegate.window makeKeyAndVisible];
23 25
 }
@@ -26,9 +28,11 @@ RCT_EXPORT_METHOD(push:(NSString*)containerId layout:(NSDictionary*)layout)
26 28
 {
27 29
 	[self assertReady];
28 30
 	//TODO implement correctly
29
-	RNNControllerFactory *factory = [[RNNControllerFactory alloc] initWithRootViewCreator:[RNNReactRootViewCreator new]];
31
+	RNNControllerFactory *factory = [[RNNControllerFactory alloc] initWithRootViewCreator:[RNNReactRootViewCreator new] store:[RNN instance].store];
30 32
 	UIViewController *newVc = [factory createLayout:layout];
31
-	id vc = [UIApplication.sharedApplication.delegate.window.rootViewController childViewControllers][0];
33
+	
34
+	id vc = [[RNN instance].store findContainerForId:containerId];
35
+	
32 36
 	[[vc navigationController]pushViewController:newVc animated:true];
33 37
 }
34 38
 

+ 2
- 1
ios/RNNControllerFactory.h ファイルの表示

@@ -5,10 +5,11 @@
5 5
 #import "RNNRootViewController.h"
6 6
 #import "RNNSideMenuController.h"
7 7
 #import "RNNSideMenuChildVC.h"
8
+#import "RNNStore.h"
8 9
 
9 10
 @interface RNNControllerFactory : NSObject
10 11
 
11
--(instancetype)initWithRootViewCreator:(id <RNNRootViewCreator>)creator;
12
+-(instancetype)initWithRootViewCreator:(id <RNNRootViewCreator>)creator store:(RNNStore*)store;
12 13
 
13 14
 -(UIViewController*)createLayout:(NSDictionary*)layout;
14 15
 

+ 20
- 11
ios/RNNControllerFactory.m ファイルの表示

@@ -7,6 +7,7 @@
7 7
 @interface RNNControllerFactory ()
8 8
 
9 9
 @property (nonatomic, strong) id<RNNRootViewCreator> creator;
10
+@property (nonatomic, strong) RNNStore *store;
10 11
 
11 12
 @end
12 13
 
@@ -15,10 +16,11 @@
15 16
 # pragma mark public
16 17
 
17 18
 
18
--(instancetype)initWithRootViewCreator:(id <RNNRootViewCreator>)creator {
19
+-(instancetype)initWithRootViewCreator:(id <RNNRootViewCreator>)creator store:(RNNStore *)store {
19 20
 	
20 21
 	self = [super init];
21 22
 	self.creator = creator;
23
+	self.store = store;
22 24
 	
23 25
 	return self;
24 26
 }
@@ -34,35 +36,42 @@
34 36
 {
35 37
 	RNNLayoutNode* node = [RNNLayoutNode create:json];
36 38
 	
39
+	UIViewController* result;
40
+	
37 41
 	if ( node.isContainer) {
38
-		
39
-		return [self createContainer:node];
42
+		result = [self createContainer:node];
40 43
 	}
41 44
 	
42 45
 	else if (node.isContainerStack)	{
43
-		return [self createContainerStack:node];
46
+		result = [self createContainerStack:node];
44 47
 	}
45 48
 	
46 49
 	else if (node.isTabs) {
47
-		return [self createTabs:node];
50
+		result = [self createTabs:node];
48 51
 	}
49 52
 	
50 53
 	else if (node.isSideMenuRoot) {
51
-		return [self createSideMenu:node];
54
+		result = [self createSideMenu:node];
52 55
 	}
53 56
 	
54 57
 	else if (node.isSideMenuCenter) {
55
-		return [self createSideMenuChild:node type:RNNSideMenuChildTypeCenter];
58
+		result = [self createSideMenuChild:node type:RNNSideMenuChildTypeCenter];
56 59
 	}
57 60
 	
58 61
 	else if (node.isSideMenuLeft) {
59
-		return [self createSideMenuChild:node type:RNNSideMenuChildTypeLeft];
62
+		result = [self createSideMenuChild:node type:RNNSideMenuChildTypeLeft];
60 63
 	}
61 64
 	else if (node.isSideMenuRight) {
62
-		return [self createSideMenuChild:node type:RNNSideMenuChildTypeRight];
65
+		result = [self createSideMenuChild:node type:RNNSideMenuChildTypeRight];
66
+	}
67
+	
68
+	if (!result) {
69
+		@throw [NSException exceptionWithName:@"UnknownControllerType" reason:[@"Unknown controller type " stringByAppendingString:node.type] userInfo:nil];
63 70
 	}
71
+
72
+	[self.store setContainer:result containerId:node.nodeId];
64 73
 	
65
-	@throw [NSException exceptionWithName:@"UnknownControllerType" reason:[@"Unknown controller type " stringByAppendingString:node.type] userInfo:nil];
74
+	return result;
66 75
 }
67 76
 
68 77
 -(RNNRootViewController*)createContainer:(RNNLayoutNode*)node
@@ -101,7 +110,7 @@
101 110
 }
102 111
 
103 112
 -(UIViewController*)createSideMenu:(RNNLayoutNode*)node
104
-{	
113
+{
105 114
 	NSMutableArray* childrenVCs = [NSMutableArray new];
106 115
 	
107 116
 	

+ 18
- 0
ios/RNNStore.h ファイルの表示

@@ -0,0 +1,18 @@
1
+//
2
+//  RNNStore.h
3
+//  ReactNativeNavigation
4
+//
5
+//  Created by Ran Greenberg on 12/02/2017.
6
+//  Copyright © 2017 Wix. All rights reserved.
7
+//
8
+
9
+#import <Foundation/Foundation.h>
10
+#import <UIKit/UIKit.h>
11
+
12
+
13
+@interface RNNStore : NSObject
14
+
15
+- (UIViewController*)findContainerForId:(NSString*)containerId;
16
+- (void)setContainer:(UIViewController*)viewController containerId:(NSString*)containerId;
17
+
18
+@end

+ 46
- 0
ios/RNNStore.m ファイルの表示

@@ -0,0 +1,46 @@
1
+//
2
+//  RNNStore.m
3
+//  ReactNativeNavigation
4
+//
5
+//  Created by Ran Greenberg on 12/02/2017.
6
+//  Copyright © 2017 Wix. All rights reserved.
7
+//
8
+
9
+#import "RNNStore.h"
10
+
11
+@interface RNNStore ()
12
+
13
+@property NSMutableDictionary *containerStore;
14
+
15
+@end
16
+
17
+@implementation RNNStore
18
+
19
+
20
+-(instancetype)init {
21
+	self = [super init];
22
+	self.containerStore = [NSMutableDictionary new];
23
+	
24
+	return self;
25
+}
26
+
27
+
28
+-(UIViewController *)findContainerForId:(NSString *)containerId {
29
+	return [self.containerStore valueForKey:containerId];
30
+}
31
+
32
+
33
+- (void)setContainer:(UIViewController*)viewController containerId:(NSString*)containerId {
34
+	if (!containerId) {
35
+		return;
36
+	}
37
+	
38
+	UIViewController *existingVewController = [self findContainerForId:containerId];
39
+	if (existingVewController) {
40
+		@throw [NSException exceptionWithName:@"MultipleContainerId" reason:[@"Container id already exists " stringByAppendingString:containerId] userInfo:nil];	}
41
+	
42
+	[self.containerStore setObject:viewController forKey:containerId];
43
+}
44
+
45
+
46
+@end

+ 8
- 0
ios/ReactNativeNavigation.xcodeproj/project.pbxproj ファイルの表示

@@ -45,6 +45,8 @@
45 45
 		263905D71E4C94970023D7D3 /* RNNSideMenuController.m in Sources */ = {isa = PBXBuildFile; fileRef = 263905D51E4C94970023D7D3 /* RNNSideMenuController.m */; };
46 46
 		263905E61E4CAC950023D7D3 /* RNNSideMenuChildVC.h in Headers */ = {isa = PBXBuildFile; fileRef = 263905E41E4CAC950023D7D3 /* RNNSideMenuChildVC.h */; };
47 47
 		263905E71E4CAC950023D7D3 /* RNNSideMenuChildVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 263905E51E4CAC950023D7D3 /* RNNSideMenuChildVC.m */; };
48
+		268692821E5054F800E2C612 /* RNNStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 268692801E5054F800E2C612 /* RNNStore.h */; };
49
+		268692831E5054F800E2C612 /* RNNStore.m in Sources */ = {isa = PBXBuildFile; fileRef = 268692811E5054F800E2C612 /* RNNStore.m */; };
48 50
 		26916C981E4B9E7700D13680 /* RNNReactRootViewCreator.h in Headers */ = {isa = PBXBuildFile; fileRef = 26916C961E4B9E7700D13680 /* RNNReactRootViewCreator.h */; };
49 51
 		26916C991E4B9E7700D13680 /* RNNReactRootViewCreator.m in Sources */ = {isa = PBXBuildFile; fileRef = 26916C971E4B9E7700D13680 /* RNNReactRootViewCreator.m */; };
50 52
 		7B1126A01E2D263F00F9B03B /* RNNEventEmitter.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B11269F1E2D263F00F9B03B /* RNNEventEmitter.m */; };
@@ -116,6 +118,8 @@
116 118
 		263905D51E4C94970023D7D3 /* RNNSideMenuController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNNSideMenuController.m; sourceTree = "<group>"; };
117 119
 		263905E41E4CAC950023D7D3 /* RNNSideMenuChildVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNNSideMenuChildVC.h; sourceTree = "<group>"; };
118 120
 		263905E51E4CAC950023D7D3 /* RNNSideMenuChildVC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNNSideMenuChildVC.m; sourceTree = "<group>"; };
121
+		268692801E5054F800E2C612 /* RNNStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNNStore.h; sourceTree = "<group>"; };
122
+		268692811E5054F800E2C612 /* RNNStore.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNNStore.m; sourceTree = "<group>"; };
119 123
 		26916C941E4B9CCC00D13680 /* RNNRootViewCreator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNRootViewCreator.h; sourceTree = "<group>"; };
120 124
 		26916C961E4B9E7700D13680 /* RNNReactRootViewCreator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNNReactRootViewCreator.h; sourceTree = "<group>"; };
121 125
 		26916C971E4B9E7700D13680 /* RNNReactRootViewCreator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNNReactRootViewCreator.m; sourceTree = "<group>"; };
@@ -232,6 +236,8 @@
232 236
 				263905D51E4C94970023D7D3 /* RNNSideMenuController.m */,
233 237
 				263905E41E4CAC950023D7D3 /* RNNSideMenuChildVC.h */,
234 238
 				263905E51E4CAC950023D7D3 /* RNNSideMenuChildVC.m */,
239
+				268692801E5054F800E2C612 /* RNNStore.h */,
240
+				268692811E5054F800E2C612 /* RNNStore.m */,
235 241
 			);
236 242
 			name = Controllers;
237 243
 			sourceTree = "<group>";
@@ -300,6 +306,7 @@
300 306
 				263905BE1E4C6F440023D7D3 /* RCCTheSideBarManagerViewController.h in Headers */,
301 307
 				263905CE1E4C6F440023D7D3 /* TheSidebarController.h in Headers */,
302 308
 				7B1126A71E2D2B6C00F9B03B /* RNNEventEmitter.h in Headers */,
309
+				268692821E5054F800E2C612 /* RNNStore.h in Headers */,
303 310
 				263905CA1E4C6F440023D7D3 /* SidebarLuvocracyAnimation.h in Headers */,
304 311
 				263905B11E4C6F440023D7D3 /* MMDrawerController.h in Headers */,
305 312
 				263905B91E4C6F440023D7D3 /* RCCDrawerController.h in Headers */,
@@ -392,6 +399,7 @@
392 399
 				263905CF1E4C6F440023D7D3 /* TheSidebarController.m in Sources */,
393 400
 				263905AF1E4C6F440023D7D3 /* MMDrawerBarButtonItem.m in Sources */,
394 401
 				7BBFE5611E253F97002A6182 /* RNN.m in Sources */,
402
+				268692831E5054F800E2C612 /* RNNStore.m in Sources */,
395 403
 				7BC9346E1E26886E00EFA125 /* RNNControllerFactory.m in Sources */,
396 404
 				263905B61E4C6F440023D7D3 /* MMExampleDrawerVisualStateManager.m in Sources */,
397 405
 				263905C91E4C6F440023D7D3 /* SidebarFlipboardAnimation.m in Sources */,

+ 4
- 0
playground/ios/playground.xcodeproj/project.pbxproj ファイルの表示

@@ -22,6 +22,7 @@
22 22
 		146834051AC3E58100842450 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; };
23 23
 		26070FD01E4B8B9D003EC8B9 /* RNNControllerFactoryTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 26070FCF1E4B8B9D003EC8B9 /* RNNControllerFactoryTest.m */; };
24 24
 		2647D65F1DB175C200B23722 /* libReactNativeNavigation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2647D65E1DB175B300B23722 /* libReactNativeNavigation.a */; };
25
+		268692851E50572700E2C612 /* RNNStoreTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 268692841E50572700E2C612 /* RNNStoreTest.m */; };
25 26
 		7B9B39861DEB4091004A6281 /* libRCTAnimation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7B9B39631DEB4076004A6281 /* libRCTAnimation.a */; };
26 27
 		7BD721FF1E2E421E00724059 /* libReactNativeNavigation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2647D65E1DB175B300B23722 /* libReactNativeNavigation.a */; };
27 28
 		832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; };
@@ -211,6 +212,7 @@
211 212
 		146833FF1AC3E56700842450 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = "../node_modules/react-native/React/React.xcodeproj"; sourceTree = "<group>"; };
212 213
 		26070FCF1E4B8B9D003EC8B9 /* RNNControllerFactoryTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNNControllerFactoryTest.m; sourceTree = "<group>"; };
213 214
 		2647D6591DB175B300B23722 /* ReactNativeNavigation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = ReactNativeNavigation.xcodeproj; path = "../node_modules/react-native-navigation/ios/ReactNativeNavigation.xcodeproj"; sourceTree = "<group>"; };
215
+		268692841E50572700E2C612 /* RNNStoreTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNNStoreTest.m; sourceTree = "<group>"; };
214 216
 		78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = "../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"; sourceTree = "<group>"; };
215 217
 		7B9B395C1DEB4076004A6281 /* RCTAnimation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTAnimation.xcodeproj; path = "../node_modules/react-native/Libraries/NativeAnimation/RCTAnimation.xcodeproj"; sourceTree = "<group>"; };
216 218
 		832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "../node_modules/react-native/Libraries/Text/RCTText.xcodeproj"; sourceTree = "<group>"; };
@@ -294,6 +296,7 @@
294 296
 			children = (
295 297
 				26070FCF1E4B8B9D003EC8B9 /* RNNControllerFactoryTest.m */,
296 298
 				00E356F01AD99517003FC87E /* Supporting Files */,
299
+				268692841E50572700E2C612 /* RNNStoreTest.m */,
297 300
 			);
298 301
 			path = playgroundTests;
299 302
 			sourceTree = "<group>";
@@ -734,6 +737,7 @@
734 737
 			isa = PBXSourcesBuildPhase;
735 738
 			buildActionMask = 2147483647;
736 739
 			files = (
740
+				268692851E50572700E2C612 /* RNNStoreTest.m in Sources */,
737 741
 				26070FD01E4B8B9D003EC8B9 /* RNNControllerFactoryTest.m in Sources */,
738 742
 			);
739 743
 			runOnlyForDeploymentPostprocessing = 0;

+ 16
- 3
playground/ios/playgroundTests/RNNControllerFactoryTest.m ファイルの表示

@@ -14,6 +14,7 @@
14 14
 
15 15
 @property (nonatomic, strong) id<RNNRootViewCreator> creator;
16 16
 @property (nonatomic, strong) RNNControllerFactory *factory;
17
+@property (nonatomic, strong) RNNStore *store;
17 18
 
18 19
 @end
19 20
 
@@ -22,8 +23,8 @@
22 23
 - (void)setUp {
23 24
 	[super setUp];
24 25
 	self.creator = nil;
25
-	self.factory = [[RNNControllerFactory alloc] initWithRootViewCreator:self.creator];
26
-	
26
+	self.store = [RNNStore new];
27
+	self.factory = [[RNNControllerFactory alloc] initWithRootViewCreator:self.creator store:self.store];
27 28
 }
28 29
 
29 30
 - (void)tearDown {
@@ -125,7 +126,7 @@
125 126
 																	   @"type": @"SideMenuRight",
126 127
 																	   @"data": @{},
127 128
 																	   @"children": @[
128
-																			   @{@"id": @"cntId_5",
129
+																			   @{@"id": @"cntId_7",
129 130
 																				 @"type": @"Container",
130 131
 																				 @"data": @{},
131 132
 																				 @"children": @[]}]}]}];
@@ -189,6 +190,18 @@
189 190
 	
190 191
 }
191 192
 
193
+- (void)testCreateLayout_addContainerToStore {
194
+	NSString *containerId = @"cntId";
195
+	UIViewController *ans = [self.factory createLayout:
196
+							 @{@"id": containerId,
197
+							   @"type": @"Container",
198
+							   @"data": @{},
199
+							   @"children": @[]}];
200
+	
201
+	UIViewController *storeAns = [self.store findContainerForId:containerId];
202
+	XCTAssertEqualObjects(ans, storeAns);
203
+}
204
+
192 205
 
193 206
 
194 207
 @end

+ 67
- 0
playground/ios/playgroundTests/RNNStoreTest.m ファイルの表示

@@ -0,0 +1,67 @@
1
+//
2
+//  RNNStoreTest.m
3
+//  playground
4
+//
5
+//  Created by Ran Greenberg on 12/02/2017.
6
+//  Copyright © 2017 Wix. All rights reserved.
7
+//
8
+
9
+#import <XCTest/XCTest.h>
10
+#import "RNNStore.m"
11
+
12
+@interface RNNStoreTest : XCTestCase
13
+
14
+@property (nonatomic, strong) RNNStore *store;
15
+
16
+@end
17
+
18
+@implementation RNNStoreTest
19
+
20
+- (void)setUp {
21
+    [super setUp];
22
+	
23
+	self.store = [RNNStore new];
24
+}
25
+
26
+
27
+- (void)testFindContainerForId_setAndGetsimpleContainerId {
28
+	NSString *containerId1 = @"cntId1";
29
+	NSString *containerId2 = @"cntId2";
30
+	
31
+	UIViewController *vc1 = [UIViewController new];
32
+	UIViewController *vc2 = [UIViewController new];
33
+	
34
+	[self.store setContainer:vc1 containerId:containerId1];
35
+	[self.store setContainer:vc2 containerId:containerId2];
36
+	
37
+	UIViewController *ans = [self.store findContainerForId:containerId1];
38
+	
39
+	XCTAssertEqualObjects(vc1, ans);
40
+	XCTAssertNotEqualObjects(vc2, ans);
41
+}
42
+
43
+- (void)testFindContainerForId_setNilContainerId {
44
+	NSString *containerId1 = nil;
45
+	UIViewController *vc1 = [UIViewController new];
46
+	[self.store setContainer:vc1 containerId:containerId1];
47
+	
48
+	UIViewController *ans = [self.store findContainerForId:containerId1];
49
+	XCTAssertNil(ans);
50
+}
51
+
52
+- (void)testFindContainerForId_setDoubleContainerId {
53
+	NSString *containerId1 = @"cntId1";
54
+	
55
+	UIViewController *vc1 = [UIViewController new];
56
+	UIViewController *vc2 = [UIViewController new];
57
+	
58
+	[self.store setContainer:vc1 containerId:containerId1];
59
+	
60
+	UIViewController *ans = [self.store findContainerForId:containerId1];
61
+	XCTAssertEqualObjects(vc1, ans);
62
+	XCTAssertThrows([self.store setContainer:vc2 containerId:containerId1]);
63
+}
64
+
65
+
66
+
67
+@end