package net.pterodactylus.xdcc.core;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.hamcrest.Matchers.instanceOf;
import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import net.pterodactylus.irc.Connection;
import net.pterodactylus.irc.ConnectionFactory;
import net.pterodactylus.xdcc.core.event.CoreStarted;
+import net.pterodactylus.xdcc.core.event.GenericError;
+import net.pterodactylus.xdcc.core.event.GenericMessage;
import net.pterodactylus.xdcc.data.Channel;
import net.pterodactylus.xdcc.data.Network;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.mockito.ArgumentCaptor;
public class CoreTest {
}
@Test
+ public void startingTheCoreWithAnEmptyNetworkStartsButDoesNotConnect() {
+ Network firstNetwork = Network.builder("FirstNet").build();
+ Channel firstChannel = new Channel(firstNetwork, "#first");
+ core.addChannel(firstChannel);
+ core.startAndWait();
+ ArgumentCaptor<Object> eventCaptor = ArgumentCaptor.forClass(Object.class);
+ verify(eventBus, times(2)).post(eventCaptor.capture());
+ assertThat(eventCaptor.getAllValues(), containsInAnyOrder(
+ instanceOf(GenericError.class), instanceOf(CoreStarted.class)
+ ));
+ verify(connectionFactory, never()).createConnection(anyString(), anyInt());
+ }
+
+ @Test
public void startingTheCoreConnectsToConfiguredNetworks() {
Network firstNetwork = Network.builder("FirstNet")
.addServer()