コード例 #1
0
  @Test(expected = IllegalArgumentException.class)
  public void shouldNotBeAbleToExitTheWrongScope() {
    final ContextScope scope =
        RoboGuice.getOrCreateBaseApplicationInjector(Robolectric.application)
            .getInstance(ContextScope.class);
    final Activity a = Robolectric.buildActivity(A.class).get();
    final Activity b = Robolectric.buildActivity(B.class).get();

    scope.enter(a);
    scope.enter(b);
    scope.exit(a);
  }
コード例 #2
0
  @Test
  public void shouldBeAbleToOpenMultipleScopes() {
    final ContextScope scope =
        RoboGuice.getOrCreateBaseApplicationInjector(Robolectric.application)
            .getInstance(ContextScope.class);
    final Activity a = Robolectric.buildActivity(A.class).get();
    final Activity b = Robolectric.buildActivity(B.class).get();

    scope.enter(a);
    scope.enter(b);
    scope.exit(b);
    scope.exit(a);
  }