diff options
author | zxu <zxu@google.com> | 2017-12-19 13:47:04 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-19 13:47:04 -0500 |
commit | 9ddf3637ac984abfe16d4ebef6ff3947b4e946c1 (patch) | |
tree | 008d6eea9adc10675c79c7152703f4fd05af4cf9 /Firestore/Example/Tests/Util | |
parent | 52cdf0b25a12b5baed8546893634dab9c1a03e56 (diff) |
Firestore `isEqual()` on Public Types (#569)
* add bone code for new isEqual and unit test for old isEqual
* add bone code for `FIRCollectionReference`, `FIRDocumentSnapshot`, `FIRFieldValue`, `FIRQuerySnapshot`, `FIRSnapshotMetadata`;
* change inconsistenciness of `FIRFieldPath.isEqual` implementation;
* add unit test (and file) for `FIRDocumentReferenceTest.m`, `FIRFieldPathTest.m`, `FIRQueryTests.testEquals`; `FIRGeoPoint` already has test and Blob is internal type.
* Implement isEqual for FIRCollectionReference
adding the working code and unit test.
* implement isEqual for FIRSnapshotMetadata
* Implement isEqual for FIRDocumentSnapshot
* Implement isEqual for FIRQuerySnapshot
* (un)implement `isEqual` for `FIRFieldValue`
Since `FIRFieldValue` both types are singleton, we do not need override `isEqual`. Add test to test the default `NSObject` `isEqual` works just fine.
* fix style with `scripts/style.sh`
* Implement hash for those with overridden isEqual without hash yet.
* refactor to use test helper functions -- FSTTestFirestore, FSTTestPath, FSTTestDocKey
* refactor using test helper `FSTTestDocSnapshot`, `FSTTestFieldPath`, `FSTTestQuery`, `FSTTestDoc`
* refactoring to use test helper method `FSTTestQuerySnapshot`,
* remove unneccessary nil-check, check isKindOfClass instead of isEqual
* refactoring: adding `FSTAPIHelpers.{h,m}`, `FSTTest{Collection,Document}Ref`, better naming and style fix
* a file forgot in last commit
* mainly clean up import and some minor refactoring
* fix style via style.sh
* minor style fix
* add pragma ignored -Wnonnull
Diffstat (limited to 'Firestore/Example/Tests/Util')
-rw-r--r-- | Firestore/Example/Tests/Util/FSTHelpers.h | 4 | ||||
-rw-r--r-- | Firestore/Example/Tests/Util/FSTHelpers.m | 15 |
2 files changed, 10 insertions, 9 deletions
diff --git a/Firestore/Example/Tests/Util/FSTHelpers.h b/Firestore/Example/Tests/Util/FSTHelpers.h index 91ccbcf..4dbf910 100644 --- a/Firestore/Example/Tests/Util/FSTHelpers.h +++ b/Firestore/Example/Tests/Util/FSTHelpers.h @@ -16,7 +16,6 @@ #import <Foundation/Foundation.h> -#import "Firestore/Source/API/FIRDocumentReference+Internal.h" #import "Firestore/Source/Core/FSTTypes.h" #import "Firestore/Source/Model/FSTDocumentDictionary.h" #import "Firestore/Source/Model/FSTDocumentKeySet.h" @@ -33,7 +32,6 @@ @class FSTPatchMutation; @class FSTQuery; @class FSTRemoteEvent; -@class FSTResourceName; @class FSTResourcePath; @class FSTSetMutation; @class FSTSnapshotVersion; @@ -145,6 +143,8 @@ NSDate *FSTTestDate(int year, int month, int day, int hour, int minute, int seco */ NSData *FSTTestData(int bytes, ...); +// Note that FIRGeoPoint is a model class in addition to an API class, so we put this helper here +// instead of FSTAPIHelpers.h /** Creates a new GeoPoint from the latitude and longitude values */ FIRGeoPoint *FSTTestGeoPoint(double latitude, double longitude); diff --git a/Firestore/Example/Tests/Util/FSTHelpers.m b/Firestore/Example/Tests/Util/FSTHelpers.m index f01bddb..f2b3605 100644 --- a/Firestore/Example/Tests/Util/FSTHelpers.m +++ b/Firestore/Example/Tests/Util/FSTHelpers.m @@ -24,6 +24,7 @@ #import "Firestore/Source/Core/FSTSnapshotVersion.h" #import "Firestore/Source/Core/FSTTimestamp.h" #import "Firestore/Source/Core/FSTView.h" +#import "Firestore/Source/Core/FSTViewSnapshot.h" #import "Firestore/Source/Local/FSTLocalViewChanges.h" #import "Firestore/Source/Local/FSTQueryData.h" #import "Firestore/Source/Model/FSTDatabaseID.h" @@ -138,7 +139,7 @@ FSTDocument *FSTTestDoc(NSString *path, FSTTestSnapshotVersion version, NSDictionary<NSString *, id> *data, BOOL hasMutations) { - FSTDocumentKey *key = [FSTDocumentKey keyWithPathString:path]; + FSTDocumentKey *key = FSTTestDocKey(path); return [FSTDocument documentWithData:FSTTestObjectValue(data) key:key version:FSTTestVersion(version) @@ -146,7 +147,7 @@ FSTDocument *FSTTestDoc(NSString *path, } FSTDeletedDocument *FSTTestDeletedDoc(NSString *path, FSTTestSnapshotVersion version) { - FSTDocumentKey *key = [FSTDocumentKey keyWithPathString:path]; + FSTDocumentKey *key = FSTTestDocKey(path); return [FSTDeletedDocument documentWithKey:key version:FSTTestVersion(version)]; } @@ -214,7 +215,7 @@ FSTSortOrder *FSTTestOrderBy(NSString *field, NSString *direction) { } NSComparator FSTTestDocComparator(NSString *fieldPath) { - FSTQuery *query = [[FSTQuery queryWithPath:[FSTResourcePath pathWithSegments:@[ @"docs" ]]] + FSTQuery *query = [FSTTestQuery(@"docs") queryByAddingSortOrder:[FSTSortOrder sortOrderWithFieldPath:FSTTestFieldPath(fieldPath) ascending:YES]]; return [query comparator]; @@ -229,7 +230,7 @@ FSTDocumentSet *FSTTestDocSet(NSComparator comp, NSArray<FSTDocument *> *docs) { } FSTSetMutation *FSTTestSetMutation(NSString *path, NSDictionary<NSString *, id> *values) { - return [[FSTSetMutation alloc] initWithKey:[FSTDocumentKey keyWithPathString:path] + return [[FSTSetMutation alloc] initWithKey:FSTTestDocKey(path) value:FSTTestObjectValue(values) precondition:[FSTPrecondition none]]; } @@ -274,7 +275,7 @@ FSTTransformMutation *FSTTestTransformMutation(NSString *path, } FSTDeleteMutation *FSTTestDeleteMutation(NSString *path) { - return [[FSTDeleteMutation alloc] initWithKey:[FSTDocumentKey keyWithPathString:path] + return [[FSTDeleteMutation alloc] initWithKey:FSTTestDocKey(path) precondition:[FSTPrecondition none]]; } @@ -334,12 +335,12 @@ FSTLocalViewChanges *FSTTestViewChanges(FSTQuery *query, NSArray<NSString *> *removedKeys) { FSTDocumentKeySet *added = [FSTDocumentKeySet keySet]; for (NSString *keyPath in addedKeys) { - FSTDocumentKey *key = [FSTDocumentKey keyWithPathString:keyPath]; + FSTDocumentKey *key = FSTTestDocKey(keyPath); added = [added setByAddingObject:key]; } FSTDocumentKeySet *removed = [FSTDocumentKeySet keySet]; for (NSString *keyPath in removedKeys) { - FSTDocumentKey *key = [FSTDocumentKey keyWithPathString:keyPath]; + FSTDocumentKey *key = FSTTestDocKey(keyPath); removed = [removed setByAddingObject:key]; } return [FSTLocalViewChanges changesForQuery:query addedKeys:added removedKeys:removed]; |