
package org.terasology.engine;

import com.google.common.collect.Iterables;
import org.junit.Before;
import org.junit.Test;
import org.terasology.context.Context;
import org.terasology.entitySystem.entity.EntityManager;
import org.terasology.entitySystem.event.internal.EventSystem;
import org.terasology.entitySystem.systems.RenderSystem;
import org.terasology.entitySystem.systems.UpdateSubscriberSystem;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

public class ComponentSystemManagerTest {

    private ComponentSystemManager sut;

    @Before
    public void setUp() {
        Context context = mock(Context.class);
        EntityManager entityManager = mock(EntityManager.class);
        when(entityManager.getEventSystem()).thenReturn(mock(EventSystem.class));
        when(context.get(EntityManager.class)).thenReturn(entityManager);
        sut = new ComponentSystemManager(context);
    }

    @Test
    public void testRegisterUpdateSubscriberAddsSubscriber() {
        UpdateSubscriberSystem system = mock(UpdateSubscriberSystem.class);

        sut.register(system);

        assertThat(Iterables.size(sut.iterateUpdateSubscribers()), is(1));
    }

    @Test
    public void testShutdownRemovesUpdateSubscribers() {
        UpdateSubscriberSystem system = mock(UpdateSubscriberSystem.class);

        sut.register(system);
        sut.shutdown();

        assertThat(Iterables.size(sut.iterateUpdateSubscribers()), is(0));
    }

    @Test
    public void testRegisterRenderSystemAddsRenderSubscriber() {
        RenderSystem system = mock(RenderSystem.class);

        sut.register(system);

        assertThat(Iterables.size(sut.iterateRenderSubscribers()), is(1));
    }

    @Test
    public void testShutdownRemovesRenderSubscribers() {
        //see https://github.com/MovingBlocks/Terasology/issues/3087#issuecomment-326409756
        RenderSystem system = mock(RenderSystem.class);

        sut.register(system);
        sut.shutdown();

        assertThat(Iterables.size(sut.iterateRenderSubscribers()), is(0));
    }

}

@@ -649,17 +649,29 @@
 anager s
-u
+ystemUnderTes
 t;%0A%0A    
@@ -981,17 +981,29 @@
        s
-u
+ystemUnderTes
 t = new 
@@ -1193,33 +1193,45 @@
 ass);%0A%0A        s
-u
+ystemUnderTes
 t.register(syste
@@ -1262,33 +1262,45 @@
 Iterables.size(s
-u
+ystemUnderTes
 t.iterateUpdateS
@@ -1474,33 +1474,45 @@
 ass);%0A%0A        s
-u
+ystemUnderTes
 t.register(syste
@@ -1516,33 +1516,45 @@
 stem);%0A        s
-u
+ystemUnderTes
 t.shutdown();%0A%0A 
@@ -1579,33 +1579,45 @@
 Iterables.size(s
-u
+ystemUnderTes
 t.iterateUpdateS
@@ -1779,33 +1779,45 @@
 ass);%0A%0A        s
-u
+ystemUnderTes
 t.register(syste
@@ -1848,33 +1848,45 @@
 Iterables.size(s
-u
+ystemUnderTes
 t.iterateRenderS
@@ -2140,17 +2140,29 @@
        s
-u
+ystemUnderTes
 t.regist
@@ -2182,17 +2182,29 @@
        s
-u
+ystemUnderTes
 t.shutdo
@@ -2245,17 +2245,29 @@
 s.size(s
-u
+ystemUnderTes
 t.iterat

Clarify naming