package ru.job4j.io;

import org.junit.Test;

import java.io.ByteArrayInputStream;

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;

/**
 * Testing input stream for even numbers.
 * @author Wamdue
 * @version 1.0
 * @since 04.12.2017
 */
public class ByteStreamTest {
    /**
     * Have input stream with even number 500.
     * Expectimg result = true.
     */
    @Test
    public void ifHaveEvenNumberiNStreanThenTrue() {
        ByteStream stream = new ByteStream();
        boolean expect = true;
        String number = "500";
        ByteArrayInputStream in = new ByteArrayInputStream(number.getBytes());
        assertThat(expect, is(stream.isNumber(in)));
    }

    /**
     * Have input stream with not even number 501.
     * Expecting result = false.
     */
    @Test
    public void ifNotHaveEvenNumberiNStreanThenFalse() {
        ByteStream stream = new ByteStream();
        boolean expect = false;
        String number = "501";
        ByteArrayInputStream in = new ByteArrayInputStream(number.getBytes());
        assertThat(expect, is(stream.isNumber(in)));
    }


}
@@ -75,16 +75,44 @@
 tStream;
+%0Aimport java.io.IOException;
 %0A%0Aimport
@@ -589,32 +589,37 @@
  %22500%22;%0A        
+try (
 ByteArrayInputSt
@@ -667,34 +667,39 @@
 .getBytes())
-;%0A
+) %7B%0A   
         
 assertThat(e
@@ -678,32 +678,33 @@
 )) %7B%0A           
+ 
 assertThat(expec
@@ -728,24 +728,101 @@
 mber(in)));%0A
+        %7D catch (IOException e) %7B%0A            e.printStackTrace();%0A        %7D%0A
     %7D%0A%0A    /
@@ -1096,24 +1096,29 @@
 1%22;%0A        
+try (
 ByteArrayInp
@@ -1174,26 +1174,31 @@
 Bytes())
-;%0A
+) %7B%0A   
         
 assertTh
@@ -1181,32 +1181,33 @@
 )) %7B%0A           
+ 
 assertThat(expec
@@ -1231,21 +1231,98 @@
 mber(in)));%0A
+        %7D catch (IOException e) %7B%0A            e.printStackTrace();%0A        %7D%0A
     %7D%0A%0A%0A%7D

Check byte stream refactoring, add try with resources in tests, task #858