// Path: src/main/java/pl/joegreen/sergeants/api/test/FakeSocket.java
// public class FakeSocket implements Socket{
// 
//     public final List<Event> receivedEvents = new CopyOnWriteArrayList<>();
//     public final Map<String, Consumer<Object[]>> registeredListeners = new ConcurrentHashMap<>();
//     boolean connected = false;
// 
//     public List<Event> getReceivedEventsByName(String name) {
//         return receivedEvents.stream().filter(event -> event.name.equals(name)).collect(Collectors.toList());
//     }
// 
//     public void injectEvent(Event event){
//         getListener(event.getName()).accept(event.getArguments());
//     }
// 
//     @Override
//     public boolean connected() {
//         return connected;
//     }
// 
//     @Override
//     public void once(String event, Consumer<Object[]> socketListener) {
//         registeredListeners.put(event, args -> {
//             socketListener.accept(args);
//             registeredListeners.remove(event);
//         });
//     }
// 
//     @Override
//     public void on(String event, Consumer<Object[]> socketListener) {
//         registeredListeners.put(event, socketListener);
//     }
// 
//     @Override
//     public void connect() {
//         connected = true;
//         getListener("connect").accept(new Object[]{});
//     }
// 
//     @Override
//     public void disconnect() {
//         connected = false;
//         getListener("disconnect").accept(new Object[]{});
//     }
// 
// 
//     private Consumer<Object[]> getListener(String connect) {
//         return registeredListeners.getOrDefault(connect, (args) -> {});
//     }
// 
// 
//     @Override
//     public void emit(String name, Object[] args) {
//         receivedEvents.add(new Event(name, args));
//     }
// 
// 
//     @Value
//     public static class Event{
//         private String name;
//         private Object[] arguments;
// 
//         public Event(String name, Object... arguments ){
//             this.name = name;
//             this.arguments = arguments;
//         }
//     }
// 
// 
// 
// }


import pl.joegreen.sergeants.api.test.FakeSocket;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;
import java.util.Arrays;
package pl.joegreen.sergeants;



public class EventMatchers {
    public static Matcher<FakeSocket.Event> withArguments(Object... arguments){
        return new TypeSafeMatcher<FakeSocket.Event>() {
            @Override
            public void describeTo(Description description) {
                description.appendText("Event arguments should be equal to ").appendValueList("(",", ", ")", arguments);
            }

            @Override
            protected boolean matchesSafely(FakeSocket.Event item) {
                return Arrays.equals(item.getArguments(), arguments);
            }

            @Override
            protected void describeMismatchSafely(FakeSocket.Event item, Description mismatchDescription) {
// Path: src/main/java/pl/joegreen/sergeants/api/test/FakeSocket.java
// public class FakeSocket implements Socket{
// 
//     public final List<Event> receivedEvents = new CopyOnWriteArrayList<>();
//     public final Map<String, Consumer<Object[]>> registeredListeners = new ConcurrentHashMap<>();
//     boolean connected = false;
// 
//     public List<Event> getReceivedEventsByName(String name) {
//         return receivedEvents.stream().filter(event -> event.name.equals(name)).collect(Collectors.toList());
//     }
// 
//     public void injectEvent(Event event){
//         getListener(event.getName()).accept(event.getArguments());
//     }
// 
//     @Override
//     public boolean connected() {
//         return connected;
//     }
// 
//     @Override
//     public void once(String event, Consumer<Object[]> socketListener) {
//         registeredListeners.put(event, args -> {
//             socketListener.accept(args);
//             registeredListeners.remove(event);
//         });
//     }
// 
//     @Override
//     public void on(String event, Consumer<Object[]> socketListener) {
//         registeredListeners.put(event, socketListener);
//     }
// 
//     @Override
//     public void connect() {
//         connected = true;
//         getListener("connect").accept(new Object[]{});
//     }
// 
//     @Override
//     public void disconnect() {
//         connected = false;
//         getListener("disconnect").accept(new Object[]{});
//     }
// 
// 
//     private Consumer<Object[]> getListener(String connect) {
//         return registeredListeners.getOrDefault(connect, (args) -> {});
//     }
// 
// 
//     @Override
//     public void emit(String name, Object[] args) {
//         receivedEvents.add(new Event(name, args));
//     }
// 
// 
//     @Value
//     public static class Event{
//         private String name;
//         private Object[] arguments;
// 
//         public Event(String name, Object... arguments ){
//             this.name = name;
//             this.arguments = arguments;
//         }
//     }
// 
// 
// 
// }


// Path: src/test/java/pl/joegreen/sergeants/EventMatchers.java
import pl.joegreen.sergeants.api.test.FakeSocket;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;
import java.util.Arrays;

package pl.joegreen.sergeants;



public class EventMatchers {
    public static Matcher<FakeSocket.Event> withArguments(Object... arguments){
        return new TypeSafeMatcher<FakeSocket.Event>() {
            @Override
            public void describeTo(Description description) {
                description.appendText("Event arguments should be equal to ").appendValueList("(",", ", ")", arguments);
            }

            @Override
            protected boolean matchesSafely(FakeSocket.Event item) {
                return Arrays.equals(item.getArguments(), arguments);
            }

            @Override
            protected void describeMismatchSafely(FakeSocket.Event item, Description mismatchDescription) {
                mismatchDescription.appendText(" Event arguments were equal to" ).appendValueList("(", ", ", ")", item.getArguments());