GDTCORRegistrarTest.m 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright 2018 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 "GDTCORTests/Unit/GDTCORTestCase.h"
  17. #import <GoogleDataTransport/GDTCORRegistrar.h>
  18. #import "GDTCORLibrary/Private/GDTCORRegistrar_Private.h"
  19. #import "GDTCORTests/Unit/Helpers/GDTCORTestPrioritizer.h"
  20. #import "GDTCORTests/Unit/Helpers/GDTCORTestUploader.h"
  21. @interface GDTCORRegistrarTest : GDTCORTestCase
  22. @property(nonatomic) GDTCORTarget target;
  23. @end
  24. @implementation GDTCORRegistrarTest
  25. - (void)setUp {
  26. [super setUp];
  27. _target = 23;
  28. }
  29. /** Tests the default initializer. */
  30. - (void)testInit {
  31. XCTAssertNotNil([[GDTCORRegistrarTest alloc] init]);
  32. }
  33. /** Test registering an uploader. */
  34. - (void)testRegisterUpload {
  35. GDTCORRegistrar *registrar = [GDTCORRegistrar sharedInstance];
  36. GDTCORTestUploader *uploader = [[GDTCORTestUploader alloc] init];
  37. XCTAssertNoThrow([registrar registerUploader:uploader target:self.target]);
  38. XCTAssertEqual(uploader, registrar.targetToUploader[@(_target)]);
  39. }
  40. /** Test registering a prioritizer. */
  41. - (void)testRegisterPrioritizer {
  42. GDTCORRegistrar *registrar = [GDTCORRegistrar sharedInstance];
  43. GDTCORTestPrioritizer *prioritizer = [[GDTCORTestPrioritizer alloc] init];
  44. XCTAssertNoThrow([registrar registerPrioritizer:prioritizer target:self.target]);
  45. XCTAssertEqual(prioritizer, registrar.targetToPrioritizer[@(_target)]);
  46. }
  47. @end