123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- //
- // RNNStoreTest.m
- // playground
- //
- // Created by Ran Greenberg on 12/02/2017.
- // Copyright © 2017 Wix. All rights reserved.
- //
-
- #import <XCTest/XCTest.h>
- #import "RNNStore.m"
-
- @interface RNNStoreTest : XCTestCase
-
- @property (nonatomic, strong) RNNStore *store;
-
- @end
-
- @implementation RNNStoreTest
-
- - (void)setUp {
- [super setUp];
-
- self.store = [RNNStore new];
- }
-
-
- - (void)testFindContainerForId_setAndGetsimpleContainerId {
- NSString *containerId1 = @"cntId1";
- NSString *containerId2 = @"cntId2";
-
- UIViewController *vc1 = [UIViewController new];
- UIViewController *vc2 = [UIViewController new];
-
- [self.store setContainer:vc1 containerId:containerId1];
- [self.store setContainer:vc2 containerId:containerId2];
-
- UIViewController *ans = [self.store findContainerForId:containerId1];
-
- XCTAssertEqualObjects(vc1, ans);
- XCTAssertNotEqualObjects(vc2, ans);
- }
-
- - (void)testSetContainer_setNilContainerId {
- NSString *containerId1 = nil;
- UIViewController *vc1 = [UIViewController new];
- [self.store setContainer:vc1 containerId:containerId1];
- XCTAssertNil([self.store findContainerForId:containerId1]);
-
- }
-
- - (void)testSetContainer_setDoubleContainerId {
- NSString *containerId1 = @"cntId1";
-
- UIViewController *vc1 = [UIViewController new];
- UIViewController *vc2 = [UIViewController new];
-
- [self.store setContainer:vc1 containerId:containerId1];
-
- UIViewController *ans = [self.store findContainerForId:containerId1];
- XCTAssertEqualObjects(vc1, ans);
- XCTAssertThrows([self.store setContainer:vc2 containerId:containerId1]);
- }
-
- - (void)testRemoveContainer_removeExistContainer {
- NSString *containerId1 = @"cntId1";
- UIViewController *vc1 = [UIViewController new];
-
- [self.store setContainer:vc1 containerId:containerId1];
-
- UIViewController *ans = [self.store findContainerForId:containerId1];
- XCTAssertEqualObjects(vc1, ans);
-
- [self.store removeContainer:containerId1];
- XCTAssertNil([self.store findContainerForId:containerId1]);
- }
-
- -(void)testPopWillRemoveVcFromStore {
- NSString *vcId = @"cnt_vc_2";
-
- [self setContainerAndRelease:vcId];
-
-
- XCTAssertNil([self.store findContainerForId:vcId]);
- }
-
- -(void)setContainerAndRelease:(NSString*)vcId {
- @autoreleasepool {
- UIViewController *vc2 = [UIViewController new];
- [self.store setContainer:vc2 containerId:vcId];
-
- XCTAssertNotNil([self.store findContainerForId:vcId]);
- }
- }
-
- @end
|