/*
 * @author Ranides Atterwim <ranides@gmail.com>
 * @copyright Ranides Atterwim
 * @license WTFPL
 * @url http://ranides.net/projects/assira
 */
package net.ranides.assira.reflection;

import java.util.Arrays;
import java.util.List;
import net.ranides.assira.collection.maps.OrderedMap;
import net.ranides.assira.collection.maps.RandomAccessMap;
import net.ranides.assira.generic.TypeToken;
import net.ranides.assira.reflection.mockup.ForIArguments;
import org.junit.Test;
import static net.ranides.assira.junit.NewAssert.*;

/**
 *
 * @author Ranides Atterwim <ranides@gmail.com>
 */
public class IArgumentsTest {
    
    @Test
    public void testMethods() {
        IArguments a1 = IArguments.typeinfo(new TypeToken<List<String>>(){});
        IArguments a2 = IArguments.typeinfo(new TypeToken<List<Integer>>(){});
        IArguments a3 = IArguments.typeinfo(
            IClass.typeinfo(int.class), 
            IClass.typeinfo(int.class)
        );
        IArguments a4 = IArguments.typeinfo(float.class, float.class);
                
        OrderedMap<String, IClass> args5 = new RandomAccessMap<>();
        args5.put("p4", IClass.typeinfo(char.class));
        args5.put("p2", IClass.typeinfo(boolean.class));
        IArguments a5 = IArguments.typeinfo(args5);
        
        OrderedMap<String, IClass> args6 = new RandomAccessMap<>();
        args6.put("p4", IClass.typeinfo(boolean.class));
        args6.put("p2", IClass.typeinfo(char.class));
        IArguments a6 = IArguments.typeinfo(args6);
        
        IClass ic = IClass.typeinfo(ForIArguments.class);
        
        assertEquals(Arrays.asList("fun6"), ic.methods().require(a1).names());
        assertEquals(Arrays.asList("fun5"), ic.methods().require(a2).names());
        assertEquals(Arrays.asList("fun1"), ic.methods().require(a3).names());
        assertEquals(Arrays.asList("fun2"), ic.methods().require(a4).names());
        assertEquals(Arrays.asList("fun7"), ic.methods().require(a5).names());
        assertEquals(Arrays.asList("fun8"), ic.methods().require(a6).names());
    }
    
}
