GULCCComponentTypeTest.m 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // Copyright 2018 Google
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #import <XCTest/XCTestCase.h>
  15. #import <GoogleUtilitiesComponents/GULCCComponentContainerInternal.h>
  16. #import <GoogleUtilitiesComponents/GULCCComponentType.h>
  17. #import <OCMock/OCMock.h>
  18. #import "GULCCTestComponents.h"
  19. @interface GULComponentTypeTest : XCTestCase
  20. @property(nonatomic, strong) id componentContainerMock;
  21. @end
  22. @implementation GULComponentTypeTest
  23. - (void)setUp {
  24. [super setUp];
  25. _componentContainerMock = OCMClassMock([GULCCComponentContainer class]);
  26. }
  27. - (void)tearDown {
  28. [super tearDown];
  29. [_componentContainerMock stopMocking];
  30. }
  31. - (void)testForwardsCallToContainer {
  32. Protocol *testProtocol = @protocol(GULCCTestProtocol);
  33. OCMExpect([self.componentContainerMock instanceForProtocol:testProtocol]);
  34. // Grab an instance from the container, through ComponentType.
  35. __unused id<GULCCTestProtocol> instance =
  36. [GULCCComponentType<id<GULCCTestProtocol>> instanceForProtocol:@protocol(GULCCTestProtocol)
  37. inContainer:self.componentContainerMock];
  38. OCMVerifyAll(self.componentContainerMock);
  39. }
  40. - (void)testMacroForwardsCallToContainer {
  41. Protocol *testProtocol = @protocol(GULCCTestProtocol);
  42. OCMExpect([self.componentContainerMock instanceForProtocol:testProtocol]);
  43. // Grab an instance from the container, through the macro that uses GULCCComponentType.
  44. __unused id<GULCCTestProtocol> instance =
  45. GUL_COMPONENT(GULCCTestProtocol, self.componentContainerMock);
  46. OCMVerifyAll(self.componentContainerMock);
  47. }
  48. @end