use of dagger.internal.TestingLoader in project dagger by square.
the class InjectionTest method getInstanceOfPrimitive.
@Test
public void getInstanceOfPrimitive() {
@Module(injects = int.class)
class TestModule {
@Provides
int provideInt() {
return 1;
}
}
ObjectGraph graph = ObjectGraph.createWith(new TestingLoader(), new TestModule());
assertEquals(1, (int) graph.get(int.class));
}
use of dagger.internal.TestingLoader in project dagger by square.
the class InjectionTest method getInstanceOfArray.
@Test
public void getInstanceOfArray() {
@Module(injects = int[].class)
class TestModule {
@Provides
int[] provideIntArray() {
return new int[] { 1, 2, 3 };
}
}
ObjectGraph graph = ObjectGraph.createWith(new TestingLoader(), new TestModule());
assertEquals("[1, 2, 3]", Arrays.toString(graph.get(int[].class)));
}
use of dagger.internal.TestingLoader in project dagger by square.
the class InjectionTest method objectGraphGetInterface.
@Test
public void objectGraphGetInterface() {
final Runnable runnable = new Runnable() {
@Override
public void run() {
}
};
@Module(injects = Runnable.class)
class TestModule {
@Provides
Runnable provideRunnable() {
return runnable;
}
}
ObjectGraph graph = ObjectGraph.createWith(new TestingLoader(), new TestModule());
graph.validate();
assertThat(graph.get(Runnable.class)).isSameAs(runnable);
}
use of dagger.internal.TestingLoader in project dagger by square.
the class InjectionTest method providerMethodsConflict.
@Test
public void providerMethodsConflict() {
@Module
class TestModule {
@Provides
A provideA1() {
throw new AssertionError();
}
@Provides
A provideA2() {
throw new AssertionError();
}
}
try {
ObjectGraph.createWith(new TestingLoader(), new TestModule());
fail();
} catch (IllegalArgumentException expected) {
}
}
use of dagger.internal.TestingLoader in project dagger by square.
the class LazyInjectionTest method getLazyDoesNotCauseProvidesResultToBeLoaded.
@Test
public void getLazyDoesNotCauseProvidesResultToBeLoaded() {
@Module
class TestModule {
@Provides
LazyProvidesResult provideLazy() {
throw new AssertionError();
}
}
ObjectGraph.createWith(new TestingLoader(), new TestModule());
assertThat(lazyProvidesResultLoaded).isFalse();
}
Aggregations