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

import java.lang.reflect.Method;
import java.util.function.Function;
import java.util.function.Supplier;
import net.ranides.assira.reflection.mockup.ForMethodUtils;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 *
 * @author Ranides Atterwim <ranides@gmail.com>
 */
public class IMethodsTest {

    @Test
    public void testInfo() throws Exception, Throwable {
        IMethods m = IMethods.function(
            (Function<String,Integer>)a -> Integer.parseInt(a),
            (Supplier<String>)() -> "text"
        );
        
        assertEquals(16, m.first().get().call("16"));
        assertEquals("text", m.list().get(1).call());
    }
    
    @Test
    public void testInfo2() {
        Method m1 = IClass.typeinfo(ForMethodUtils.MCP.class).method("some1").get().reflective();
        Method m2 = IClass.typeinfo(ForMethodUtils.MCP.class).method("some2").get().reflective();
        IMethods m = IMethods.typeinfo(m1, m2);

        ForMethodUtils.MCP<?> mcp = new ForMethodUtils.MCP<>();        
        assertEquals(777, m.first().get().call(mcp));
        assertEquals(444, m.list().get(1).apply(mcp));
    }
    
}
