package com.github.pedrovgs.androidwifiadb;

import com.github.pedrovgs.androidwifiadb.adb.ADB;
import java.util.LinkedList;
import org.junit.Test;
import org.mockito.Mock;

import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

public class AndroidWiFiADBTest extends UnitTest {

  @Mock private ADB adb;
  @Mock private View view;

  @Test public void shouldShowErrorIfADBIsNotInstalled() {
    AndroidWiFiADB sut = givenAnAndroidWiFiADB();
    givenADBIsNotInstalled();

    sut.connectDevices();

    verify(view).showADBNotInstalledNotification();
  }

  @Test public void shouldShowNoConnectedDevicesNotificationIfThereAreNotConnectedDevicesByUSB() {
    AndroidWiFiADB sut = givenAnAndroidWiFiADB();
    givenThereAreNoConnectedDevices();

    sut.connectDevices();

    verify(view).showNoConnectedDevicesNotification();
  }

  private void givenThereAreNoConnectedDevices() {
    when(adb.isInstalled()).thenReturn(true);
    when(adb.getDevicesConnectedByUSB()).thenReturn(new LinkedList<Device>());
  }

  private void givenADBIsNotInstalled() {
    when(adb.isInstalled()).thenReturn(false);
  }

  private AndroidWiFiADB givenAnAndroidWiFiADB() {
    return new AndroidWiFiADB(adb, view);
  }
}

@@ -114,24 +114,47 @@
 LinkedList;%0A
+import java.util.List;%0A
 import org.j
@@ -160,24 +160,24 @@
 junit.Test;%0A
-
 import org.m
@@ -325,16 +325,124 @@
 Test %7B%0A%0A
+  private static final int SOME_DEVICES = 4;%0A  private static final String ANY_DEVICE_NAME = %22Device n%C2%BA %22;%0A%0A
   @Mock 
@@ -918,32 +918,32 @@
 nectDevices();%0A%0A
-
     verify(view)
@@ -978,32 +978,1772 @@
 ication();%0A  %7D%0A%0A
+  @Test public void shouldShowDevicesConnectedIfADBWiFiWhenConnectionIsEstablished() %7B%0A    AndroidWiFiADB sut = givenAnAndroidWiFiADB();%0A    List%3CDevice%3E devices = givenThereAreSomeDevicesConnectedByUSB();%0A    givenDevicesAreConnectedSuccessfully(devices);%0A%0A    sut.connectDevices();%0A%0A    for (Device device : devices) %7B%0A      verify(view).showConnectedDeviceNotification(device);%0A    %7D%0A  %7D%0A%0A  @Test public void shouldShowDeviceConnectionErrorWhenConnectionIsNotExtablished() %7B%0A    AndroidWiFiADB sut = givenAnAndroidWiFiADB();%0A    List%3CDevice%3E devices = givenThereAreSomeDevicesConnectedByUSB();%0A    givenDevicesAreNotConnectedSuccessfully(devices);%0A%0A    sut.connectDevices();%0A%0A    for (Device device : devices) %7B%0A      verify(view).showErrorConnectingDeviceNotification(device);%0A    %7D%0A  %7D%0A%0A  private void givenDevicesAreNotConnectedSuccessfully(List%3CDevice%3E devices) %7B%0A    for (Device device : devices) %7B%0A      device.setConnected(false);%0A    %7D%0A    when(adb.getDevicesConnectedByUSB()).thenReturn(devices);%0A    when(adb.connectDevices(devices)).thenReturn(devices);%0A  %7D%0A%0A  private void givenDevicesAreConnectedSuccessfully(List%3CDevice%3E devices) %7B%0A    for (Device device : devices) %7B%0A      device.setConnected(true);%0A    %7D%0A    when(adb.getDevicesConnectedByUSB()).thenReturn(devices);%0A    when(adb.connectDevices(devices)).thenReturn(devices);%0A  %7D%0A%0A  private List%3CDevice%3E givenThereAreSomeDevicesConnectedByUSB() %7B%0A    when(adb.isInstalled()).thenReturn(true);%0A    List%3CDevice%3E devices = new LinkedList%3CDevice%3E();%0A    for (int i = 0; i %3C SOME_DEVICES; i++) %7B%0A      String name = ANY_DEVICE_NAME + i;%0A      String id = String.valueOf(i);%0A      Device device = new Device(name, id);%0A      devices.add(device);%0A    %7D%0A    return devices;%0A  %7D%0A%0A
   private void g

Add some more tests to the AndroidWiFiADB class