package com.acabra.gtechdevalgs.litcode.dynamicprog;

import com.acabra.gtechdevalgs.TestUtils;
import com.acabra.gtechdevalgs.litcode.trees.TreeNode;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

class RobHousesTreeTest {
    private RobHousesTree underTest;

    @BeforeEach
    public void setup() {
        underTest = new RobHousesTree();
    }

    @Test
    public void mustReturn7() {
        Integer[] nodes = {3,2,3,null,3,null,1};
        TreeNode root = TestUtils.buildTree(nodes);
        int expected = 7;
        Assertions.assertEquals(expected, underTest.rob(root));
    }

    @Test
    public void mustReturn9() {
        Integer[] nodes = {3,4,5,1,3,null,1};
        TreeNode root = TestUtils.buildTree(nodes);
        int expected = 9;
        Assertions.assertEquals(expected, underTest.rob(root));
    }

    @Test
    public void mustReturn105() {
        Integer[] nodes = {5, null, 3, null, null, 2, null, null, null, null, null, null, 100};
        TreeNode root = TestUtils.buildTree(nodes);
        int expected = 105;
        Assertions.assertEquals(expected, underTest.rob(root));
    }

    @Test
    public void mustReturn176() {
        Integer[] nodes = {79,99,77,null,null,null,69,null,60,53,null,73,11,null,null,null,62,27,62,null,null,98,50,null,null,90,48,82,null,null,null,55,64,null,null,73,56,6,47,null,93,null,null,75,44,30,82,null,null,null,null,null,null,57,36,89,42,null,null,76,10,null,null,null,null,null,32,4,18,null,null,1,7,null,null,42,64,null,null,39,76,null,null,6,null,66,8,96,91,38,38,null,null,null,null,74,42,null,null,null,10,40,5,null,null,null,null,28,8,24,47,null,null,null,17,36,50,19,63,33,89,null,null,null,null,null,null,null,null,94,72,null,null,79,25,null,null,51,null,70,84,43,null,64,35,null,null,null,null,40,78,null,null,35,42,98,96,null,null,82,26,null,null,null,null,48,91,null,null,35,93,86,42,null,null,null,null,0,61,null,null,67,null,53,48,null,null,82,30,null,97,null,null,null,1,null,null};
        TreeNode root = TestUtils.buildTree(nodes);
        int expected = 176;
        Assertions.assertEquals(expected, underTest.rob(root));
    }

    @Test
    public void mustReturn12() {
        Integer[] nodes = {5,3,6,1,4,null,null,null,2};
        TreeNode root = TestUtils.buildTree(nodes);
        int expected = 12;
        Assertions.assertEquals(expected, underTest.rob(root));
    }
}