TinyBDeviceTest.java 文件源码

java
阅读 24 收藏 0 点赞 0 评论 0

项目:bluetooth-manager-tinyb 作者:
@Test
public void testEnableConnectedNotifications() throws Exception {
    Notification<Boolean> notification = mock(Notification.class);
    ArgumentCaptor<BluetoothNotification> captor = ArgumentCaptor.forClass(BluetoothNotification.class);
    doNothing().when(bluetoothDevice).enableConnectedNotifications(captor.capture());

    tinyBDevice.enableConnectedNotifications(notification);

    verify(bluetoothDevice, times(1)).enableConnectedNotifications(captor.getValue());
    verifyNoMoreInteractions(bluetoothDevice, notification);

    captor.getValue().run(CONNECTED);
    verify(notification, times(1)).notify(CONNECTED);

    doThrow(RuntimeException.class).when(notification).notify(anyBoolean());
    captor.getValue().run(false);
    verify(notification, times(1)).notify(false);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号