FIRInstallationsItemTests.m 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright 2019 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 <XCTest/XCTest.h>
  17. #import "FirebaseInstallations/Source/Library/FIRInstallationsItem.h"
  18. #import "FirebaseInstallations/Source/Library/InstallationsStore/FIRInstallationsStoredItem.h"
  19. @interface FIRInstallationsItemTests : XCTestCase
  20. @end
  21. // TODO: Add more tests.
  22. @implementation FIRInstallationsItemTests
  23. - (void)testInstallationsItemInit {
  24. NSString *appID = @"appID";
  25. NSString *name = @"name";
  26. FIRInstallationsItem *item = [[FIRInstallationsItem alloc] initWithAppID:appID
  27. firebaseAppName:name];
  28. XCTAssertEqualObjects(item.appID, appID);
  29. XCTAssertEqualObjects(item.firebaseAppName, name);
  30. }
  31. - (void)testItemUpdateWithStoredItem {
  32. // TODO: Implement.
  33. }
  34. - (void)testGenerateFID {
  35. NSString *FID1 = [FIRInstallationsItem generateFID];
  36. [self assertValidFID:FID1];
  37. NSString *FID2 = [FIRInstallationsItem generateFID];
  38. XCTAssertEqual(FID2.length, 22);
  39. [self assertValidFID:FID2];
  40. XCTAssertNotEqualObjects(FID1, FID2);
  41. }
  42. - (void)assertValidFID:(NSString *)FID {
  43. XCTAssertEqual(FID.length, 22);
  44. XCTAssertFalse([FID containsString:@"/"]);
  45. XCTAssertFalse([FID containsString:@"+"]);
  46. }
  47. @end