• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DaggerMockRule类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中it.cosenonjaviste.daggermock.DaggerMockRule的典型用法代码示例。如果您正苦于以下问题:Java DaggerMockRule类的具体用法?Java DaggerMockRule怎么用?Java DaggerMockRule使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DaggerMockRule类属于it.cosenonjaviste.daggermock包,在下文中一共展示了DaggerMockRule类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: EspressoDaggerMockRule

import it.cosenonjaviste.daggermock.DaggerMockRule; //导入依赖的package包/类
public EspressoDaggerMockRule() {
    super(AppComponent.class, new AppModule(getApp()));
    set(new DaggerMockRule.ComponentSetter<AppComponent>() {
        @Override public void setComponent(AppComponent component) {
            getApp().container().setAppComponent(component);
        }
    });
}
 
开发者ID:albertopeam,项目名称:Android-Infrastructure,代码行数:9,代码来源:EspressoDaggerMockRule.java


示例2: testInjectFromComponentWithSingleParameter

import it.cosenonjaviste.daggermock.DaggerMockRule; //导入依赖的package包/类
@Test
public void testInjectFromComponentWithSingleParameter() {
    try {
        DaggerMockRule<MyComponent> rule = new DaggerMockRule<>(MyComponent.class, new MyModule());
        rule.apply(null, null, this).evaluate();

        fail();
    } catch (Throwable e) {
        assertThat(e.getMessage())
                .contains("Error instantiating class")
                .contains("defined as parameter in InjectFromComponent annotation")
                .contains(MyActivityConstructorError.class.getName());
    }
}
 
开发者ID:fabioCollini,项目名称:DaggerMock,代码行数:15,代码来源:InjectFromComponentWithSingleParameterErrorTest.java


示例3: testInjectFromComponentWithMultipleParameters

import it.cosenonjaviste.daggermock.DaggerMockRule; //导入依赖的package包/类
@Test
public void testInjectFromComponentWithMultipleParameters() {
    try {
        DaggerMockRule<MyComponent> rule = new DaggerMockRule<>(MyComponent.class, new MyModule());
        rule.apply(null, null, this).evaluate();

        fail();
    } catch (Throwable e) {
        assertThat(e.getMessage())
                .contains("it.cosenonjaviste.daggermock.injectfromcomponentwithparams.Service1 field not found in class " +
                        "it.cosenonjaviste.daggermock.injectfromcomponentwithparams.MyActivity, it's defined as parameter in InjectFromComponent annotation");
    }
}
 
开发者ID:fabioCollini,项目名称:DaggerMock,代码行数:14,代码来源:InjectFromComponentWithMultipleParametersErrorTest.java


示例4: testInjectFromComponentWithSingleParameter

import it.cosenonjaviste.daggermock.DaggerMockRule; //导入依赖的package包/类
@Test
public void testInjectFromComponentWithSingleParameter() {
    try {
        DaggerMockRule<MyComponent> rule = new DaggerMockRule<>(MyComponent.class, new MyModule());
        rule.apply(null, null, this).evaluate();

        fail();
    } catch (Throwable e) {
        assertThat(e.getMessage())
                .isEqualTo("Inject method for class it.cosenonjaviste.daggermock.injectfromcomponentwithparams.MyActivity "
                        + "not found in component it.cosenonjaviste.daggermock.injectfromcomponentwithparams.InjectFromComponentInjectMethodNotFoundErrorTest$MyComponent or in subComponents");
    }
}
 
开发者ID:fabioCollini,项目名称:DaggerMock,代码行数:14,代码来源:InjectFromComponentInjectMethodNotFoundErrorTest.java


示例5: testSubComponentError

import it.cosenonjaviste.daggermock.DaggerMockRule; //导入依赖的package包/类
@Test
public void testSubComponentError() throws Throwable {
    try {
        DaggerMockRule<MyComponent> rule = new DaggerMockRule<>(MyComponent.class, new MyModule());
        rule.apply(null, null, this).evaluate();

        fail();
    } catch (Throwable e) {
        assertThat(e.getMessage())
                .contains("Error while trying to override subComponents objects")
                .contains("java.lang.Integer")
                .contains("java.lang.Short")
                .doesNotContain("java.lang.Long");
    }
}
 
开发者ID:fabioCollini,项目名称:DaggerMock,代码行数:16,代码来源:SubComponentErrorTest.java


示例6: testErrorOnStaticMethods

import it.cosenonjaviste.daggermock.DaggerMockRule; //导入依赖的package包/类
@Test
public void testErrorOnStaticMethods() throws Throwable {
    try {
        DaggerMockRule<MyComponent> rule = new DaggerMockRule<>(MyComponent.class, new MyModule());
        rule.apply(null, null, this).evaluate();
        fail();
    } catch (RuntimeException e) {
        assertThat(e.getMessage()).isEqualTo("The following methods must be non static:\n" +
                "public static it.cosenonjaviste.daggermock.modulemethodsvisibility.MyService it.cosenonjaviste.daggermock.modulemethodsvisibility.StaticMethodTest$MyModule.provideMyService()");
    }
}
 
开发者ID:fabioCollini,项目名称:DaggerMock,代码行数:12,代码来源:StaticMethodTest.java


示例7: testErrorOnFinalMethods

import it.cosenonjaviste.daggermock.DaggerMockRule; //导入依赖的package包/类
@Test
public void testErrorOnFinalMethods() throws Throwable {
    try {
        DaggerMockRule<MyComponent> rule = new DaggerMockRule<>(MyComponent.class, new MyModule());
        rule.apply(null, null, this).evaluate();
        fail();
    } catch (RuntimeException e) {
        assertThat(e.getMessage()).isEqualTo("The following methods must be non final:\n" +
                "public final it.cosenonjaviste.daggermock.modulemethodsvisibility.MyService it.cosenonjaviste.daggermock.modulemethodsvisibility.FinalMethodTest$MyModule.provideMyService()\n" +
                " or using MockMaker plugin");
    }
}
 
开发者ID:fabioCollini,项目名称:DaggerMock,代码行数:13,代码来源:FinalMethodTest.java


示例8: testErrorOnPackageMethods

import it.cosenonjaviste.daggermock.DaggerMockRule; //导入依赖的package包/类
@Test
public void testErrorOnPackageMethods() throws Throwable {
    try {
        DaggerMockRule<MyComponent> rule = new DaggerMockRule<>(MyComponent.class, new MyModule());
        rule.apply(null, null, this).evaluate();
        fail();
    } catch (RuntimeException e) {
        assertThat(e.getMessage()).isEqualTo("The following methods must be declared public or protected:\n" +
                "it.cosenonjaviste.daggermock.modulemethodsvisibility.MyService it.cosenonjaviste.daggermock.modulemethodsvisibility.PackageMethodTest$MyModule.provideMyService()");
    }
}
 
开发者ID:fabioCollini,项目名称:DaggerMock,代码行数:12,代码来源:PackageMethodTest.java


示例9: MyRule

import it.cosenonjaviste.daggermock.DaggerMockRule; //导入依赖的package包/类
public MyRule() {
    super(MyComponent.class, new MyModule());
    providesMock(MyService.class, new DaggerMockRule.MockInitializer<MyService>() {
        @Override
        public void init(MyService mock) {
            when(mock.getWithParam(anyInt())).thenReturn("default");
        }
    });
}
 
开发者ID:fabioCollini,项目名称:DaggerMock,代码行数:10,代码来源:ProvidesMockWithInitMethodTest.java


示例10: testErrorWhenDefiningUsingProvidesMockAFieldThatDoesntOverride

import it.cosenonjaviste.daggermock.DaggerMockRule; //导入依赖的package包/类
@Test
public void testErrorWhenDefiningUsingProvidesMockAFieldThatDoesntOverride() {
    try {
        DaggerMockRule<MyComponent> rule = new DaggerMockRule<>(MyComponent.class, new MyModule())
                .providesMock(MyService.class, MyService2.class);
        rule.apply(null, null, this).evaluate();

        fail();
    } catch (Throwable e) {
        assertThat(e.getMessage())
                .contains("Error while trying to override objects")
                .contains(MyService2.class.getName());
    }
}
 
开发者ID:fabioCollini,项目名称:DaggerMock,代码行数:15,代码来源:ProvideTest.java


示例11: testErrorWhenDefiningUsingProvidesAFieldThatDoesntOverride

import it.cosenonjaviste.daggermock.DaggerMockRule; //导入依赖的package包/类
@Test
public void testErrorWhenDefiningUsingProvidesAFieldThatDoesntOverride() {
    try {
        DaggerMockRule<MyComponent> rule = new DaggerMockRule<>(MyComponent.class, new MyModule())
                .provides(MyService.class, new MyService())
                .provides(MyService2.class, new MyService2());
        rule.apply(null, null, this).evaluate();

        fail();
    } catch (Throwable e) {
        assertThat(e.getMessage())
                .contains("Error while trying to override objects")
                .contains(MyService2.class.getName());
    }
}
 
开发者ID:fabioCollini,项目名称:DaggerMock,代码行数:16,代码来源:ProvideTest.java


示例12: testErrorWhenDefiningAFieldThatDoesntOverride

import it.cosenonjaviste.daggermock.DaggerMockRule; //导入依赖的package包/类
@Test
public void testErrorWhenDefiningAFieldThatDoesntOverride() {
    try {
        DaggerMockRule<MyComponent> rule = new DaggerMockRule<>(MyComponent.class, new MyModule());
        rule.apply(null, null, this).evaluate();

        fail();
    } catch (Throwable e) {
        assertThat(e.getMessage())
                .contains("Error while trying to override objects")
                .contains(MyService2.class.getName());
    }
}
 
开发者ID:fabioCollini,项目名称:DaggerMock,代码行数:14,代码来源:SimpleTest.java


示例13: EspressoDaggerMockRule

import it.cosenonjaviste.daggermock.DaggerMockRule; //导入依赖的package包/类
public EspressoDaggerMockRule() {
    super(AppComponent.class, new AppModule(), new NetModule());
    customizeBuilder(new BuilderCustomizer<AppComponent.Builder>() {
        @Override public AppComponent.Builder customize(AppComponent.Builder builder) {
            return builder.application(getApp());
        }
    });
    set(new DaggerMockRule.ComponentSetter<AppComponent>() {
        @Override public void setComponent(AppComponent component) {
            component.inject(getApp());
        }
    });
}
 
开发者ID:fabioCollini,项目名称:DaggerMock,代码行数:14,代码来源:EspressoDaggerMockRule.java


示例14: EspressoDaggerMockRule

import it.cosenonjaviste.daggermock.DaggerMockRule; //导入依赖的package包/类
public EspressoDaggerMockRule() {
    super(AppComponent.class, new AppModule(getApp()));
    set(new DaggerMockRule.ComponentSetter<AppComponent>() {
        @Override public void setComponent(AppComponent component) {
            getApp().setComponent(component);
        }
    });
}
 
开发者ID:fabioCollini,项目名称:DaggerMock,代码行数:9,代码来源:EspressoDaggerMockRule.java


示例15: MyRule

import it.cosenonjaviste.daggermock.DaggerMockRule; //导入依赖的package包/类
public MyRule() {
    super(MyComponent.class, new MyModule());
    set(new DaggerMockRule.ComponentSetter<MyComponent>() {
        @Override public void setComponent(MyComponent component) {
            getApp().setComponent(component);
        }
    });
}
 
开发者ID:fabioCollini,项目名称:DaggerMock,代码行数:9,代码来源:MyRule.java



注:本文中的it.cosenonjaviste.daggermock.DaggerMockRule类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CMenuItem类代码示例发布时间:2022-05-22
下一篇:
Java SMTestRunnerConnectionUtil类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap