@isTest
private class Consum_ApplyUtilTest {
    @isTest
    static void getWD_addday_Test() {
        // Base is FRI
        Date baseDate = Date.newInstance(2020, 1, 10);
        System.assertEquals(Date.newInstance(2020, 1, 10), Consum_ApplyUtil.getWD_addday(baseDate, 0));
        System.assertEquals(Date.newInstance(2020, 1, 13), Consum_ApplyUtil.getWD_addday(baseDate, 1));
        System.assertEquals(Date.newInstance(2020, 1, 14), Consum_ApplyUtil.getWD_addday(baseDate, 2));
        System.assertEquals(Date.newInstance(2020, 1, 15), Consum_ApplyUtil.getWD_addday(baseDate, 3));
        System.assertEquals(Date.newInstance(2020, 1, 16), Consum_ApplyUtil.getWD_addday(baseDate, 4));
        System.assertEquals(Date.newInstance(2020, 1, 17), Consum_ApplyUtil.getWD_addday(baseDate, 5));
        System.assertEquals(Date.newInstance(2020, 1, 20), Consum_ApplyUtil.getWD_addday(baseDate, 6));
        System.assertEquals(Date.newInstance(2020, 1, 21), Consum_ApplyUtil.getWD_addday(baseDate, 7));
        System.assertEquals(Date.newInstance(2020, 1, 22), Consum_ApplyUtil.getWD_addday(baseDate, 8));
        System.assertEquals(Date.newInstance(2020, 1, 23), Consum_ApplyUtil.getWD_addday(baseDate, 9));
        System.assertEquals(Date.newInstance(2020, 1, 24), Consum_ApplyUtil.getWD_addday(baseDate, 10));

        System.assertEquals(Date.newInstance(2020, 1, 9), Consum_ApplyUtil.getWD_addday(baseDate, -1));
        System.assertEquals(Date.newInstance(2020, 1, 8), Consum_ApplyUtil.getWD_addday(baseDate, -2));
        System.assertEquals(Date.newInstance(2020, 1, 7), Consum_ApplyUtil.getWD_addday(baseDate, -3));
        System.assertEquals(Date.newInstance(2020, 1, 6), Consum_ApplyUtil.getWD_addday(baseDate, -4));
        System.assertEquals(Date.newInstance(2020, 1, 3), Consum_ApplyUtil.getWD_addday(baseDate, -5));
        System.assertEquals(Date.newInstance(2020, 1, 2), Consum_ApplyUtil.getWD_addday(baseDate, -6));
        System.assertEquals(Date.newInstance(2020, 1, 1), Consum_ApplyUtil.getWD_addday(baseDate, -7));
        System.assertEquals(Date.newInstance(2019,12,31), Consum_ApplyUtil.getWD_addday(baseDate, -8));
        System.assertEquals(Date.newInstance(2019,12,30), Consum_ApplyUtil.getWD_addday(baseDate, -9));
        System.assertEquals(Date.newInstance(2019,12,27), Consum_ApplyUtil.getWD_addday(baseDate, -10));

        // Base is SAT
        baseDate = Date.newInstance(2020, 1, 11);
        System.assertEquals(Date.newInstance(2020, 1, 10), Consum_ApplyUtil.getWD_addday(baseDate, 0));
        System.assertEquals(Date.newInstance(2020, 1, 13), Consum_ApplyUtil.getWD_addday(baseDate, 1));
        System.assertEquals(Date.newInstance(2020, 1, 14), Consum_ApplyUtil.getWD_addday(baseDate, 2));
        System.assertEquals(Date.newInstance(2020, 1, 15), Consum_ApplyUtil.getWD_addday(baseDate, 3));
        System.assertEquals(Date.newInstance(2020, 1, 16), Consum_ApplyUtil.getWD_addday(baseDate, 4));
        System.assertEquals(Date.newInstance(2020, 1, 17), Consum_ApplyUtil.getWD_addday(baseDate, 5));
        System.assertEquals(Date.newInstance(2020, 1, 20), Consum_ApplyUtil.getWD_addday(baseDate, 6));
        System.assertEquals(Date.newInstance(2020, 1, 21), Consum_ApplyUtil.getWD_addday(baseDate, 7));
        System.assertEquals(Date.newInstance(2020, 1, 22), Consum_ApplyUtil.getWD_addday(baseDate, 8));
        System.assertEquals(Date.newInstance(2020, 1, 23), Consum_ApplyUtil.getWD_addday(baseDate, 9));
        System.assertEquals(Date.newInstance(2020, 1, 24), Consum_ApplyUtil.getWD_addday(baseDate, 10));

        System.assertEquals(Date.newInstance(2020, 1,10), Consum_ApplyUtil.getWD_addday(baseDate, -1));
        System.assertEquals(Date.newInstance(2020, 1, 9), Consum_ApplyUtil.getWD_addday(baseDate, -2));
        System.assertEquals(Date.newInstance(2020, 1, 8), Consum_ApplyUtil.getWD_addday(baseDate, -3));
        System.assertEquals(Date.newInstance(2020, 1, 7), Consum_ApplyUtil.getWD_addday(baseDate, -4));
        System.assertEquals(Date.newInstance(2020, 1, 6), Consum_ApplyUtil.getWD_addday(baseDate, -5));
        System.assertEquals(Date.newInstance(2020, 1, 3), Consum_ApplyUtil.getWD_addday(baseDate, -6));
        System.assertEquals(Date.newInstance(2020, 1, 2), Consum_ApplyUtil.getWD_addday(baseDate, -7));
        System.assertEquals(Date.newInstance(2020, 1, 1), Consum_ApplyUtil.getWD_addday(baseDate, -8));
        System.assertEquals(Date.newInstance(2019,12,31), Consum_ApplyUtil.getWD_addday(baseDate, -9));
        System.assertEquals(Date.newInstance(2019,12,30), Consum_ApplyUtil.getWD_addday(baseDate, -10));
        System.assertEquals(Date.newInstance(2019,12,27), Consum_ApplyUtil.getWD_addday(baseDate, -11));

        // Base is SUN
        baseDate = Date.newInstance(2020, 1, 12);
        System.assertEquals(Date.newInstance(2020, 1, 10), Consum_ApplyUtil.getWD_addday(baseDate, 0));
        System.assertEquals(Date.newInstance(2020, 1, 13), Consum_ApplyUtil.getWD_addday(baseDate, 1));
        System.assertEquals(Date.newInstance(2020, 1, 14), Consum_ApplyUtil.getWD_addday(baseDate, 2));
        System.assertEquals(Date.newInstance(2020, 1, 15), Consum_ApplyUtil.getWD_addday(baseDate, 3));
        System.assertEquals(Date.newInstance(2020, 1, 16), Consum_ApplyUtil.getWD_addday(baseDate, 4));
        System.assertEquals(Date.newInstance(2020, 1, 17), Consum_ApplyUtil.getWD_addday(baseDate, 5));
        System.assertEquals(Date.newInstance(2020, 1, 20), Consum_ApplyUtil.getWD_addday(baseDate, 6));
        System.assertEquals(Date.newInstance(2020, 1, 21), Consum_ApplyUtil.getWD_addday(baseDate, 7));
        System.assertEquals(Date.newInstance(2020, 1, 22), Consum_ApplyUtil.getWD_addday(baseDate, 8));
        System.assertEquals(Date.newInstance(2020, 1, 23), Consum_ApplyUtil.getWD_addday(baseDate, 9));
        System.assertEquals(Date.newInstance(2020, 1, 24), Consum_ApplyUtil.getWD_addday(baseDate, 10));

        System.assertEquals(Date.newInstance(2020, 1,10), Consum_ApplyUtil.getWD_addday(baseDate, -1));
        System.assertEquals(Date.newInstance(2020, 1, 9), Consum_ApplyUtil.getWD_addday(baseDate, -2));
        System.assertEquals(Date.newInstance(2020, 1, 8), Consum_ApplyUtil.getWD_addday(baseDate, -3));
        System.assertEquals(Date.newInstance(2020, 1, 7), Consum_ApplyUtil.getWD_addday(baseDate, -4));
        System.assertEquals(Date.newInstance(2020, 1, 6), Consum_ApplyUtil.getWD_addday(baseDate, -5));
        System.assertEquals(Date.newInstance(2020, 1, 3), Consum_ApplyUtil.getWD_addday(baseDate, -6));
        System.assertEquals(Date.newInstance(2020, 1, 2), Consum_ApplyUtil.getWD_addday(baseDate, -7));
        System.assertEquals(Date.newInstance(2020, 1, 1), Consum_ApplyUtil.getWD_addday(baseDate, -8));
        System.assertEquals(Date.newInstance(2019,12,31), Consum_ApplyUtil.getWD_addday(baseDate, -9));
        System.assertEquals(Date.newInstance(2019,12,30), Consum_ApplyUtil.getWD_addday(baseDate, -10));
        System.assertEquals(Date.newInstance(2019,12,27), Consum_ApplyUtil.getWD_addday(baseDate, -11));

        // Base is MON
        baseDate = Date.newInstance(2020, 1, 13);
        System.assertEquals(Date.newInstance(2020, 1, 13), Consum_ApplyUtil.getWD_addday(baseDate, 0));
        System.assertEquals(Date.newInstance(2020, 1, 14), Consum_ApplyUtil.getWD_addday(baseDate, 1));
        System.assertEquals(Date.newInstance(2020, 1, 15), Consum_ApplyUtil.getWD_addday(baseDate, 2));
        System.assertEquals(Date.newInstance(2020, 1, 16), Consum_ApplyUtil.getWD_addday(baseDate, 3));
        System.assertEquals(Date.newInstance(2020, 1, 17), Consum_ApplyUtil.getWD_addday(baseDate, 4));
        System.assertEquals(Date.newInstance(2020, 1, 20), Consum_ApplyUtil.getWD_addday(baseDate, 5));
        System.assertEquals(Date.newInstance(2020, 1, 21), Consum_ApplyUtil.getWD_addday(baseDate, 6));
        System.assertEquals(Date.newInstance(2020, 1, 22), Consum_ApplyUtil.getWD_addday(baseDate, 7));
        System.assertEquals(Date.newInstance(2020, 1, 23), Consum_ApplyUtil.getWD_addday(baseDate, 8));
        System.assertEquals(Date.newInstance(2020, 1, 24), Consum_ApplyUtil.getWD_addday(baseDate, 9));
        System.assertEquals(Date.newInstance(2020, 1, 27), Consum_ApplyUtil.getWD_addday(baseDate, 10));

        System.assertEquals(Date.newInstance(2020, 1,10), Consum_ApplyUtil.getWD_addday(baseDate, -1));
        System.assertEquals(Date.newInstance(2020, 1, 9), Consum_ApplyUtil.getWD_addday(baseDate, -2));
        System.assertEquals(Date.newInstance(2020, 1, 8), Consum_ApplyUtil.getWD_addday(baseDate, -3));
        System.assertEquals(Date.newInstance(2020, 1, 7), Consum_ApplyUtil.getWD_addday(baseDate, -4));
        System.assertEquals(Date.newInstance(2020, 1, 6), Consum_ApplyUtil.getWD_addday(baseDate, -5));
        System.assertEquals(Date.newInstance(2020, 1, 3), Consum_ApplyUtil.getWD_addday(baseDate, -6));
        System.assertEquals(Date.newInstance(2020, 1, 2), Consum_ApplyUtil.getWD_addday(baseDate, -7));
        System.assertEquals(Date.newInstance(2020, 1, 1), Consum_ApplyUtil.getWD_addday(baseDate, -8));
        System.assertEquals(Date.newInstance(2019,12,31), Consum_ApplyUtil.getWD_addday(baseDate, -9));
        System.assertEquals(Date.newInstance(2019,12,30), Consum_ApplyUtil.getWD_addday(baseDate, -10));
        System.assertEquals(Date.newInstance(2019,12,27), Consum_ApplyUtil.getWD_addday(baseDate, -11));
    }
}