package eu.lestard.easydi;

import org.junit.Before;
import org.junit.Test;

import static org.assertj.core.api.Assertions.assertThat;

/**
 * This test is used to verify the behaviour of EasyDI dealing with interfaces.
 */
public class InterfaceTest {

    public static interface A {
    }

    public static interface B {
    }

    public static class ExampleOne implements A{
    }

    public static class ExampleTwo implements A, B {
    }

    private EasyDI easyDI;

    @Before
    public void setup() throws Exception{
        easyDI = new EasyDI();
    }


    @Test
    public void success_withBinding(){
        easyDI.bindInterface(A.class, ExampleOne.class);

        final A instance = easyDI.getInstance(A.class);
        assertThat(instance).isNotNull().isInstanceOf(ExampleOne.class);
    }


    @Test(expected = IllegalStateException.class)
    public void fail_noBinding(){
        easyDI.getInstance(A.class);
    }

    @Test
    public void success_lastBindingIsUsed(){
        easyDI.bindInterface(A.class, ExampleOne.class);
        easyDI.bindInterface(A.class, ExampleTwo.class);

        final A instance = easyDI.getInstance(A.class);
        assertThat(instance).isNotNull().isInstanceOf(ExampleTwo.class);
    }
}

@@ -70,16 +70,48 @@
 .Test;%0A%0A
+import javax.inject.Singleton;%0A%0A
 import s
@@ -148,26 +148,17 @@
 ertions.
-assertThat
+*
 ;%0A%0A/**%0A 
@@ -460,24 +460,25 @@
  B %7B%0A    %7D%0A%0A
+%0A
     private 
@@ -1176,32 +1176,32 @@
 tance(A.class);%0A
-
         assertTh
@@ -1263,10 +1263,651 @@
 ;%0A    %7D%0A
+%0A%0A%0A    @Singleton%0A    public static interface WannabeSingleton %7B%7D%0A%0A    public static class NonSingleton implements WannabeSingleton%7B%7D%0A%0A    /**%0A     * The %7B@link javax.inject.Singleton%7D annotation is ignored when it is added to%0A     * interfaces.%0A     */%0A    @Test%0A    public void fail_interfacesCantBeMarkedAsSingleton()%7B%0A%0A        easyDI.bindInterface(WannabeSingleton.class, NonSingleton.class);%0A%0A        final WannabeSingleton instanceOne = easyDI.getInstance(WannabeSingleton.class);%0A        final WannabeSingleton instanceTwo = easyDI.getInstance(WannabeSingleton.class);%0A%0A        assertThat(instanceOne).isNotSameAs(instanceTwo);%0A    %7D%0A
 %7D%0A

Add Test case for Interface with @Singleton annotation