FIRSnapshotMetadataTests.mm 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 <FirebaseFirestore/FIRSnapshotMetadata.h>
  17. #import <XCTest/XCTest.h>
  18. #import "Firestore/Source/API/FIRSnapshotMetadata+Internal.h"
  19. NS_ASSUME_NONNULL_BEGIN
  20. @interface FIRSnapshotMetadataTests : XCTestCase
  21. @end
  22. @implementation FIRSnapshotMetadataTests
  23. - (void)testEquals {
  24. FIRSnapshotMetadata *foo = [[FIRSnapshotMetadata alloc] initWithPendingWrites:YES fromCache:YES];
  25. FIRSnapshotMetadata *fooDup = [[FIRSnapshotMetadata alloc] initWithPendingWrites:YES
  26. fromCache:YES];
  27. FIRSnapshotMetadata *bar = [[FIRSnapshotMetadata alloc] initWithPendingWrites:YES fromCache:NO];
  28. FIRSnapshotMetadata *baz = [[FIRSnapshotMetadata alloc] initWithPendingWrites:NO fromCache:YES];
  29. XCTAssertEqualObjects(foo, fooDup);
  30. XCTAssertNotEqualObjects(foo, bar);
  31. XCTAssertNotEqualObjects(foo, baz);
  32. XCTAssertNotEqualObjects(bar, baz);
  33. XCTAssertEqual([foo hash], [fooDup hash]);
  34. XCTAssertNotEqual([foo hash], [bar hash]);
  35. XCTAssertNotEqual([foo hash], [baz hash]);
  36. XCTAssertNotEqual([bar hash], [baz hash]);
  37. }
  38. - (void)testProperties {
  39. FIRSnapshotMetadata *metadata = [[FIRSnapshotMetadata alloc] initWithPendingWrites:YES
  40. fromCache:NO];
  41. XCTAssertTrue(metadata.hasPendingWrites);
  42. XCTAssertTrue(metadata.pendingWrites);
  43. XCTAssertFalse(metadata.isFromCache);
  44. XCTAssertFalse(metadata.fromCache);
  45. }
  46. @end
  47. NS_ASSUME_NONNULL_END