FSTAPIHelpers.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 "Firestore/Example/Tests/Util/FSTHelpers.h"
  18. @class FIRCollectionReference;
  19. @class FIRDocumentReference;
  20. @class FIRDocumentSnapshot;
  21. @class FIRFirestore;
  22. @class FIRQuerySnapshot;
  23. NS_ASSUME_NONNULL_BEGIN
  24. #if __cplusplus
  25. extern "C" {
  26. #endif
  27. /** A convenience method for creating dummy singleton FIRFirestore for tests. */
  28. FIRFirestore *FSTTestFirestore();
  29. /** A convenience method for creating a doc snapshot for tests. */
  30. FIRDocumentSnapshot *FSTTestDocSnapshot(NSString *path,
  31. FSTTestSnapshotVersion version,
  32. NSDictionary<NSString *, id> *_Nullable data,
  33. BOOL hasMutations,
  34. BOOL fromCache);
  35. /** A convenience method for creating a collection reference from a path string. */
  36. FIRCollectionReference *FSTTestCollectionRef(NSString *path);
  37. /** A convenience method for creating a document reference from a path string. */
  38. FIRDocumentReference *FSTTestDocRef(NSString *path);
  39. /**
  40. * A convenience method for creating a particular query snapshot for tests.
  41. *
  42. * @param path To be used in constructing the query.
  43. * @param oldDocs Provides the prior set of documents in the QuerySnapshot. Each dictionary entry
  44. * maps to a document, with the key being the document id, and the value being the document
  45. * contents.
  46. * @param docsToAdd Specifies data to be added into the query snapshot as of now. Each dictionary
  47. * entry maps to a document, with the key being the document id, and the value being the document
  48. * contents.
  49. * @param hasPendingWrites Whether the query snapshot has pending writes to the server.
  50. * @param fromCache Whether the query snapshot is cache result.
  51. * @returns A query snapshot that consists of both sets of documents.
  52. */
  53. FIRQuerySnapshot *FSTTestQuerySnapshot(
  54. NSString *path,
  55. NSDictionary<NSString *, NSDictionary<NSString *, id> *> *oldDocs,
  56. NSDictionary<NSString *, NSDictionary<NSString *, id> *> *docsToAdd,
  57. BOOL hasPendingWrites,
  58. BOOL fromCache);
  59. #if __cplusplus
  60. } // extern "C"
  61. #endif
  62. NS_ASSUME_NONNULL_END