Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions Tests/Unit/InstallationUnitTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,18 @@ - (void)testInstallationImmutableFieldsCannotBeChanged {
PFInstallation *installation = [PFInstallation currentInstallation];
installation.deviceToken = @"11433856eed2f1285fb3aa11136718c1198ed5647875096952c66bf8cb976306";

PFAssertThrowsInvalidArgumentException(installation[@"deviceType"] = @"android",
@"Should throw an exception for trying to change deviceType.");
PFAssertThrowsInvalidArgumentException(installation[@"installationId"] = @"a"
@"Should throw an exception for trying to change installationId.");
PFAssertThrowsInvalidArgumentException(installation[@"localeIdentifier"] = @"a"
@"Should throw an exception for trying to change installationId.");
PFAssertThrowsInvalidArgumentException(installation[@"deviceType"] = @"android");
PFAssertThrowsInvalidArgumentException(installation[@"installationId"] = @"a");
PFAssertThrowsInvalidArgumentException(installation[@"localeIdentifier"] = @"a");
}

- (void)testInstallationImmutableFieldsCannotBeDeleted {
PFInstallation *installation = [PFInstallation currentInstallation];
installation.deviceToken = @"11433856eed2f1285fb3aa11136718c1198ed5647875096952c66bf8cb976306";

PFAssertThrowsInvalidArgumentException([installation removeObjectForKey:@"deviceType"],
@"Should throw an exception for trying to delete deviceType.");
PFAssertThrowsInvalidArgumentException([installation removeObjectForKey:@"installationId"],
@"Should throw an exception for trying to delete installationId.");
PFAssertThrowsInvalidArgumentException([installation removeObjectForKey:@"localeIdentifier"],
@"Should throw an exception for trying to delete installationId.");
PFAssertThrowsInvalidArgumentException([installation removeObjectForKey:@"deviceType"]);
PFAssertThrowsInvalidArgumentException([installation removeObjectForKey:@"installationId"]);
PFAssertThrowsInvalidArgumentException([installation removeObjectForKey:@"localeIdentifier"]);
}

@end
9 changes: 4 additions & 5 deletions Tests/Unit/ObjectSubclassTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,12 @@ - (void)testExplicitConstructor {

- (void)testSubclassConstructor {
PFObject *theFlash = [PFObject objectWithClassName:@"Person"];
XCTAssertFalse([theFlash isKindOfClass:[TheFlash class]], @"We're living the past.");
XCTAssertFalse([theFlash isKindOfClass:[TheFlash class]]);

[TheFlash registerSubclass];
theFlash = [PFObject objectWithClassName:@"Person"];
XCTAssertTrue([theFlash isKindOfClass:[TheFlash class]], @"In the future, everyone is the Flash.");
XCTAssertEqualObjects(@"The Flash", [(TheFlash*)theFlash flashName], @"The Flash's name should be The Flash, duh.");
XCTAssertTrue([theFlash isKindOfClass:[TheFlash class]]);
XCTAssertEqualObjects(@"The Flash", [(TheFlash*)theFlash flashName]);
}

- (void)testSubclassesMustHaveTheirParentsParseClassName {
Expand All @@ -162,8 +162,7 @@ - (void)testSubclassesMustHaveTheirParentsParseClassName {

- (void)testDirtyPointerDetection {
[ClassWithDirtyingConstructor registerSubclass];
XCTAssertThrows([ClassWithDirtyingConstructor objectWithoutDataWithObjectId:@"NotUsed"],
@"ClassWithDirtyingConstructor has an invalid init method");
XCTAssertThrows([ClassWithDirtyingConstructor objectWithoutDataWithObjectId:@"NotUsed"]);
[PFObject unregisterSubclass:[ClassWithDirtyingConstructor class]];
}

Expand Down
17 changes: 8 additions & 9 deletions Tests/Unit/ObjectUnitTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,19 @@ - (void)testConstructorFromDictionary {
@"object" : object };
PFObject *object2 = [PFObject objectWithClassName:@"Test" dictionary:validDictionary];
XCTAssertNotNil(object2);
XCTAssertEqualObjects(string, object2[@"string"], @"'string' should be set via constructor");
XCTAssertEqualObjects(number, object2[@"number"], @"'number' should be set via constructor");
XCTAssertEqualObjects(date, object2[@"date"], @"'date' should be set via constructor");
XCTAssertEqualObjects(object, object2[@"object"], @"'object' should be set via constructor");
XCTAssertEqualObjects(null, object2[@"null"], @"'null' should be set via constructor");
XCTAssertEqualObjects(data, object2[@"data"], @"'data' should be set via constructor");
XCTAssertEqualObjects(string, object2[@"string"]);
XCTAssertEqualObjects(number, object2[@"number"]);
XCTAssertEqualObjects(date, object2[@"date"]);
XCTAssertEqualObjects(object, object2[@"object"]);
XCTAssertEqualObjects(null, object2[@"null"]);
XCTAssertEqualObjects(data, object2[@"data"]);

validDictionary = @{ @"array" : @[ object, object2 ],
@"dictionary" : @{@"bar" : date, @"score" : number} };
PFObject *object3 = [PFObject objectWithClassName:@"Stuff" dictionary:validDictionary];
XCTAssertNotNil(object3);
XCTAssertEqualObjects(validDictionary[@"array"], object3[@"array"], @"'array' should be set via constructor");
XCTAssertEqualObjects(validDictionary[@"dictionary"], object3[@"dictionary"],
@"'dictionary' should be set via constructor");
XCTAssertEqualObjects(validDictionary[@"array"], object3[@"array"]);
XCTAssertEqualObjects(validDictionary[@"dictionary"], object3[@"dictionary"]);

// Dictionary constructor relise on constraints enforced by PFObject -setObject:forKey:
NSDictionary *invalidDictionary = @{ @"1" : @"2",
Expand Down
6 changes: 3 additions & 3 deletions Tests/Unit/ParseModuleUnitTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ - (void)testModuleSelectors {
// Spin the run loop, as the delegate messages are being called on the main thread
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1.0]];

XCTAssertTrue(module.didInitializeCalled, @"Did initialize method should be called on a module.");
XCTAssertTrue(module.didInitializeCalled);
}

- (void)testWeakModuleReference {
Expand All @@ -53,7 +53,7 @@ - (void)testWeakModuleReference {
}

[collection parseDidInitializeWithApplicationId:nil clientKey:nil];
XCTAssertEqual([collection modulesCount], 0, @"Module should be removed from the collection.");
XCTAssertEqual([collection modulesCount], 0);
}

- (void)testModuleRemove {
Expand All @@ -69,7 +69,7 @@ - (void)testModuleRemove {

XCTAssertTrue([collection containsModule:moduleB]);
XCTAssertFalse([collection containsModule:moduleA]);
XCTAssertEqual([collection modulesCount], 1, @"Module should be removed from the collection");
XCTAssertEqual([collection modulesCount], 1);
}

- (void)testNilModule {
Expand Down
3 changes: 1 addition & 2 deletions Tests/Unit/UserUnitTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ @implementation UserUnitTests
///--------------------------------------

- (void)testConstructorsClassNameValidation {
PFAssertThrowsInvalidArgumentException([[PFUser alloc] initWithClassName:@"notuserclass"],
@"Should throw an exception for invalid classname");
PFAssertThrowsInvalidArgumentException([[PFUser alloc] initWithClassName:@"notuserclass"]);
}

- (void)testImmutableFieldsCannotBeChanged {
Expand Down