package ru.job4j.treeTest;

import org.junit.Test;
import ru.job4j.simpleTree.Tree;

import java.util.Iterator;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;

public class TreeTest {
    @Test
    public void when6ElFindLastThen6() {
        Tree<Integer> tree = new Tree<Integer>(1);
        tree.add(1, 2);
        tree.add(1, 3);
        tree.add(1, 4);
        tree.add(4, 5);
        tree.add(5, 6);
        assertThat(
                tree.findBy(6).isPresent(),
                is(true)
        );
    }

    @Test
    public void when6ElFindNotExitThenOptionEmpty() {
        Tree<Integer> tree = new Tree<Integer>(1);
        tree.add(1, 2);
        assertThat(
                tree.findBy(7).isPresent(),
                is(false)
        );
    }

    @Test
    public void whenNextValueIsOne() {
        Tree<Integer> tree = new Tree<Integer>(1);
        assertThat(tree.iterator().next(), is(1));
    }

    @Test
    public void whenhasNextIsTrue() {
        Tree<Integer> tree = new Tree<Integer>(1);
        assertThat(tree.iterator().hasNext(), is(true));
    }

    @Test
    public void whenTreeIsBinary() {
        Tree<Integer> tree = new Tree<>(1);
        tree.add(1,2);
        tree.add(1,3);
        assertThat(tree.isBinary(), is(true));
    }
}

@@ -716,36 +716,32 @@
 at(%0A            
-    
 tree.findBy(7).i
@@ -744,36 +744,32 @@
 7).isPresent(),%0A
-    
             is(f
@@ -1155,16 +1155,20 @@
 IsBinary
+True
 () %7B%0A   
@@ -1306,11 +1306,233 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void whenTreeIsBinaryFalse() %7B%0A        Tree%3CInteger%3E tree = new Tree%3C%3E(1);%0A        tree.add(1,2);%0A        tree.add(1,3);%0A        tree.add(1,4);%0A        assertThat(tree.isBinary(), is(false));%0A    %7D%0A%0A
 %0A%7D%0A

task #1712