From 4b37e950f75b6c785d871934fed6aee9e20b8c55 Mon Sep 17 00:00:00 2001 From: gonzalonunez Date: Thu, 27 Aug 2015 15:42:13 -0400 Subject: [PATCH] Checks for nil applicationId and clientKey --- Parse/Parse.m | 5 +++-- Tests/Unit/ParseSetupUnitTests.m | 8 ++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Parse/Parse.m b/Parse/Parse.m index bd2b535af..1a4f49f0d 100644 --- a/Parse/Parse.m +++ b/Parse/Parse.m @@ -55,8 +55,9 @@ + (void)initialize { ///-------------------------------------- + (void)setApplicationId:(NSString *)applicationId clientKey:(NSString *)clientKey { - // TODO: (nlutsenko) Add assert and unit test here that checks applicationId, clientKey not being nil. - + PFConsistencyAssert([applicationId length], @"'applicationId' should not be nil."); + PFConsistencyAssert([clientKey length], @"'clientKey' should not be nil."); + // Setup new manager first, so it's 100% ready whenever someone sends a request for anything. ParseManager *manager = [[ParseManager alloc] initWithApplicationId:applicationId clientKey:clientKey]; [manager configureWithApplicationGroupIdentifier:applicationGroupIdentifier_ diff --git a/Tests/Unit/ParseSetupUnitTests.m b/Tests/Unit/ParseSetupUnitTests.m index db10ae946..0b7032b79 100644 --- a/Tests/Unit/ParseSetupUnitTests.m +++ b/Tests/Unit/ParseSetupUnitTests.m @@ -45,4 +45,12 @@ - (void)testInitializeWithLDSAfterInitializeShouldThrowException { [Parse setApplicationId:@"a" clientKey:@"b"]; PFAssertThrowsInconsistencyException([Parse enableLocalDatastore]); } + +- (void)testInitializeWithNilApplicationIdNilClientKeyShouldThrowException { + NSString *yolo = nil; + PFAssertThrowsInconsistencyException([Parse setApplicationId:yolo clientKey:yolo]); + PFAssertThrowsInconsistencyException([Parse setApplicationId:yolo clientKey:@"a"]); + PFAssertThrowsInconsistencyException([Parse setApplicationId:@"a" clientKey:yolo]); +} + @end