forked from parse-community/Parse-SDK-iOS-OSX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ObjectUtilitiesTests.m
49 lines (39 loc) · 1.78 KB
/
ObjectUtilitiesTests.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/**
* Copyright (c) 2015-present, Parse, LLC.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import "PFFieldOperation.h"
#import "PFObjectUtilities.h"
#import "PFOperationSet.h"
#import "PFTestCase.h"
@interface ObjectUtilitiesTests : PFTestCase
@end
@implementation ObjectUtilitiesTests
- (void)testApplyFieldOperation {
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
id value = [PFObjectUtilities newValueByApplyingFieldOperation:[PFSetOperation setWithValue:@"b"]
toDictionary:dictionary
forKey:@"a"];
XCTAssertEqualObjects(value, @"b");
XCTAssertEqualObjects(dictionary, @{ @"a" : @"b" });
}
- (void)testApplyOperationSet {
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
PFOperationSet *operationSet = [[PFOperationSet alloc] init];
operationSet[@"a"] = [PFSetOperation setWithValue:@"b"];
[PFObjectUtilities applyOperationSet:operationSet toDictionary:dictionary];
XCTAssertEqualObjects(dictionary, @{ @"a" : @"b" });
}
- (void)testEquality {
XCTAssertFalse([PFObjectUtilities isObject:nil equalToObject:@"a"]);
XCTAssertFalse([PFObjectUtilities isObject:@"a" equalToObject:nil]);
XCTAssertFalse([PFObjectUtilities isObject:@"a" equalToObject:@"b"]);
XCTAssertFalse([PFObjectUtilities isObject:@"a" equalToObject:[NSDate date]]);
XCTAssertTrue([PFObjectUtilities isObject:nil equalToObject:nil]);
XCTAssertTrue([PFObjectUtilities isObject:@"a" equalToObject:@"a"]);
}
@end