FSTAPIHelpers.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * Copyright 2017 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import <Foundation/Foundation.h>
  17. #import "FirebaseFirestore/FIRCollectionReference.h"
  18. #import "FirebaseFirestore/FIRDocumentSnapshot.h"
  19. #import "FirebaseFirestore/FIRFirestore.h"
  20. #import "FirebaseFirestore/FIRQuerySnapshot.h"
  21. #import "Firestore/Example/Tests/Util/FSTHelpers.h"
  22. NS_ASSUME_NONNULL_BEGIN
  23. #if __cplusplus
  24. extern "C" {
  25. #endif
  26. /** A convenience method for creating dummy singleton FIRFirestore for tests. */
  27. FIRFirestore *FSTTestFirestore();
  28. /** A convenience method for creating a doc snapshot for tests. */
  29. FIRDocumentSnapshot *FSTTestDocSnapshot(NSString *path,
  30. FSTTestSnapshotVersion version,
  31. NSDictionary<NSString *, id> *data,
  32. BOOL hasMutations,
  33. BOOL fromCache);
  34. /** A convenience method for creating a collection reference from a path string. */
  35. FIRCollectionReference *FSTTestCollectionRef(NSString *path);
  36. /** A convenience method for creating a document reference from a path string. */
  37. FIRDocumentReference *FSTTestDocRef(NSString *path);
  38. /**
  39. * A convenience method for creating a particular query snapshot for tests.
  40. *
  41. * @param path To be used in constructing the query.
  42. * @param oldDocs Provides the prior set of documents in the QuerySnapshot. Each dictionary entry
  43. * maps to a document, with the key being the document id, and the value being the document
  44. * contents.
  45. * @param docsToAdd Specifies data to be added into the query snapshot as of now. Each dictionary
  46. * entry maps to a document, with the key being the document id, and the value being the document
  47. * contents.
  48. * @param hasPendingWrites Whether the query snapshot has pending writes to the server.
  49. * @param fromCache Whether the query snapshot is cache result.
  50. * @returns A query snapshot that consists of both sets of documents.
  51. */
  52. FIRQuerySnapshot *FSTTestQuerySnapshot(
  53. NSString *path,
  54. NSDictionary<NSString *, NSDictionary<NSString *, id> *> *oldDocs,
  55. NSDictionary<NSString *, NSDictionary<NSString *, id> *> *docsToAdd,
  56. BOOL hasPendingWrites,
  57. BOOL fromCache);
  58. #if __cplusplus
  59. } // extern "C"
  60. #endif
  61. NS_ASSUME_NONNULL_END