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

import java.io.IOException;
import java.io.OutputStream;
import java.util.function.Function;
import javax.annotation.Resource;
import net.ranides.assira.junit.TestContract;
import org.junit.Assert;

/**
 *
 * @author Ranides Atterwim <ranides@gmail.com>
 */
public class OutputStreamTester {
    
    @Resource(name = "ostream.bytes!")
    private Function<OutputStream, byte[]> os;
    
    @TestContract
    public void writeBasic(OutputStream ostream) throws IOException {
        ostream.write(new byte[]{7,8,9});
        ostream.write(new byte[]{1,1,4,5,6,1,1}, 2, 3);
        ostream.write(71);
        
		ostream.close();
        Assert.assertArrayEquals(new byte[]{7,8,9, 4,5,6, 71}, os.apply(ostream));
    }

}
