@Before public void setUp() { initMocks(this); testFieldInjector = new TestFieldInjector(testCase, roboUtils, reflectionUtils); when(roboUtils.getInjector(any(Context.class))).thenReturn(injector); when(injector.getInstance(EventManager.class)).thenReturn(eventManager); }
@Test public void shouldEnterIntoTestSubjectContextIfTestSubjectIsAContext() { when(testCase.getTestSubjectClassType()).thenReturn(Activity.class); when(injector.getInstance(Activity.class)).thenReturn(activity); when(reflectionUtils.objectIsOfAnyType(activity, Context.class)).thenReturn(true); when(roboUtils.getInjector(activity)).thenReturn(injector); testFieldInjector.setupTestCase(); verify(roboUtils).enterContext(activity); }
@Test public void shouldGetTheInjectorForTheCurrentContextOnlyAfterEnteringCurrentContext() { when(testCase.getTestSubjectClassType()).thenReturn(Activity.class); when(injector.getInstance(Activity.class)).thenReturn(activity); when(reflectionUtils.objectIsOfAnyType(activity, Context.class)).thenReturn(true); when(roboUtils.getInjector(activity)).thenReturn(injector); testFieldInjector.setupTestCase(); InOrder inOrder = inOrder(roboUtils); inOrder.verify(roboUtils).enterContext(activity); inOrder.verify(roboUtils).getInjector(activity); }