package cucumber.runtime.java.guice;

import cucumber.runtime.java.ObjectFactory;
import org.junit.Ignore;
import org.junit.Test;

import java.io.IOException;
import java.util.Properties;

import static org.junit.Assert.*;

public class GuiceFactoryTest {
    @Test
    public void shouldGiveUsNewInstancesForEachScenario() throws IOException {
        ObjectFactory factory = new GuiceFactory();
        factory.addClass(Mappings.class);

        // Scenario 1
        factory.createInstances();
        Mappings o1 = factory.getInstance(Mappings.class);
        factory.disposeInstances();

        // Scenario 2
        factory.createInstances();
        Mappings o2 = factory.getInstance(Mappings.class);
        factory.disposeInstances();

        assertNotNull(o1);
        assertNotSame(o1, o2);
    }

    @Test
    public void testShouldGiveTheSameInstanceWithinAScenario() throws Exception {
        ObjectFactory factory = new GuiceFactory();
        factory.addClass(Mappings.class);

        factory.createInstances();
        assertSame(factory.getInstance(Mappings.class), factory.getInstance(Mappings.class));
        factory.disposeInstances();
    }
}
@@ -79,33 +79,8 @@
 ry;%0A
-import org.junit.Ignore;%0A
 impo
@@ -130,37 +130,8 @@
 ion;
-%0Aimport java.util.Properties;
 %0A%0Aim

Remove the unused import