GDTCORTransportTest.m 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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/GDTCOREvent.h>
  18. #import <GoogleDataTransport/GDTCORTransport.h>
  19. #import "GDTCORLibrary/Private/GDTCORTransport_Private.h"
  20. #import "GDTCORTests/Common/Fakes/GDTCORTransformerFake.h"
  21. #import "GDTCORTests/Unit/Helpers/GDTCORDataObjectTesterClasses.h"
  22. @interface GDTCORTransportTest : GDTCORTestCase
  23. @end
  24. @implementation GDTCORTransportTest
  25. /** Tests the default initializer. */
  26. - (void)testInit {
  27. XCTAssertNotNil([[GDTCORTransport alloc] initWithMappingID:@"1" transformers:nil target:1]);
  28. XCTAssertNil([[GDTCORTransport alloc] initWithMappingID:@"" transformers:nil target:1]);
  29. }
  30. /** Tests sending a telemetry event. */
  31. - (void)testSendTelemetryEvent {
  32. GDTCORTransport *transport = [[GDTCORTransport alloc] initWithMappingID:@"1"
  33. transformers:nil
  34. target:1];
  35. transport.transformerInstance = [[GDTCORTransformerFake alloc] init];
  36. GDTCOREvent *event = [transport eventForTransport];
  37. event.dataObject = [[GDTCORDataObjectTesterSimple alloc] init];
  38. XCTAssertNoThrow([transport sendTelemetryEvent:event]);
  39. }
  40. /** Tests sending a data event. */
  41. - (void)testSendDataEvent {
  42. GDTCORTransport *transport = [[GDTCORTransport alloc] initWithMappingID:@"1"
  43. transformers:nil
  44. target:1];
  45. transport.transformerInstance = [[GDTCORTransformerFake alloc] init];
  46. GDTCOREvent *event = [transport eventForTransport];
  47. event.dataObject = [[GDTCORDataObjectTesterSimple alloc] init];
  48. XCTAssertNoThrow([transport sendDataEvent:event]);
  49. }
  50. @end