Toothpick { public static Scope openScope(Object name) { return openScope(name, true); } protected  Toothpick(); static Scope openRootScope(); static Scope openRootScope(ScopeConfig scopeConfig); static boolean isRootScopeOpen(); static boolean isScopeOpen(Object name); static Scope openScopes(Object... names); static Scope openScope(Object name); static Scope openScope(Object name, ScopeConfig scopeConfig); static void closeScope(Object name); static void reset(); static void reset(Scope scope); static void release(Scope scope); static void inject(Object obj, Scope scope); static void setConfiguration(Configuration configuration);  }
@Test public void getScope_shouldNotReturnNull_whenNoScopeByThisKeyWasCreated() { Scope scope = Toothpick.openScope(this); assertThat(scope, notNullValue()); }
@Test(expected = IllegalArgumentException.class) public void getScope_shouldFail_whenScopeNameIsNull() { Toothpick.openScope(null); fail("Should throw an exception"); }
@Test public void getScope_shouldReturnAScope_whenThisScopeByThisKeyWasCreated() { Scope scope = Toothpick.openScope(this); Scope scope2 = Toothpick.openScope(this); assertThat(scope, notNullValue()); assertThat(scope, sameInstance(scope2)); }
@Test public void createScope_shouldMarkThisScopeAsOpen() { ScopeImpl scope = (ScopeImpl) Toothpick.openScope("foo"); assertThat(scope.isOpen, is(true)); }
@Test public void getOrCreateScope_shouldReturnSameScope_WhenOneWasCreatedWithSameKey() { Scope scope = Toothpick.openScope("foo"); Scope scope2 = Toothpick.openScope("foo"); assertThat(scope, sameInstance(scope2)); }