use of se.jbee.inject.Injector in project silk by jbee.
the class TestExample2Binds method thatInstancesAToDAreDifferent.
@Test
public void thatInstancesAToDAreDifferent() {
Injector injector = Bootstrap.injector(Example2Module.class);
Decoupling a = injector.resolve(dependency(instance(named("a"), raw(Decoupling.class))));
Decoupling b = injector.resolve(dependency(instance(named("b"), raw(Decoupling.class))));
Decoupling c = injector.resolve(dependency(instance(named("c"), raw(Decoupling.class))));
Decoupling d = injector.resolve(dependency(instance(named("d"), raw(Decoupling.class))));
assertNotSame(a, b);
assertNotSame(a, c);
assertNotSame(a, d);
assertNotSame(b, c);
assertNotSame(b, d);
assertNotSame(c, d);
}
use of se.jbee.inject.Injector in project silk by jbee.
the class TestInjectronBinds method thatInjectorIsAvailableByDefault.
@Test
public void thatInjectorIsAvailableByDefault() {
Injector resolved = injector.resolve(dependency(Injector.class));
assertSame(injector, resolved);
}
use of se.jbee.inject.Injector in project silk by jbee.
the class TestIssue1 method thatBundleCanBeBootstrapped.
@Test
public void thatBundleCanBeBootstrapped() {
Injector injector = Bootstrap.injector(Bundle1.class);
B b = injector.resolve(dependency(B.class));
B leftB = injector.resolve(dependency(B.class).named(left));
assertNotSame(b, leftB);
assertEquals(2, leftB.as.length);
C c = injector.resolve(dependency(C.class).injectingInto(instance(left, raw(B.class))));
D d = injector.resolve(dependency(D.class).injectingInto(instance(left, raw(B.class))));
assertEqualSets(new A[] { c, d }, leftB.as);
}
use of se.jbee.inject.Injector in project silk by jbee.
the class TestLambdaBinds method thatLambdasCanBeUsedToDescribeModules.
@Test
public void thatLambdasCanBeUsedToDescribeModules() {
Injector injector = Bootstrap.injector(LambdaBindsModule.class);
assertEquals(1, injector.resolve(dependency(int.class)).intValue());
}
use of se.jbee.inject.Injector in project silk by jbee.
the class TestLinker method thatMonomodalModulesCanBeInstalledTwice.
/**
* A monomodal module has just one initial state (or no state). Therefore it can be determined
* that installing it twice or more does not make sense.
*/
@Test
public void thatMonomodalModulesCanBeInstalledTwice() {
Injector injector = Bootstrap.injector(LinkerBundle.class);
assertEquals(42, injector.resolve(dependency(Integer.class)).intValue());
}
Aggregations