/*
 * The MIT License (MIT)
 *
 * Copyright (c) 2017 Abhijit Parida <abhijitparida.me@gmail.com>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

package app.abhijit.iter.models;

import org.junit.Test;

import static org.junit.Assert.assertEquals;

public class SubjectTest {

    @Test
    public void generateBunkStats_NumberOfTotalClassesIsSmall_DoesNotContainRepeatedStats() {
        Subject subject = new Subject();
        subject.attendance = 100;
        subject.theoryClassesPresent = 9;
        subject.theoryClasses = 9;

        String bunkStats = "";
        bunkStats += "Bunk 3 classes for 75% attendance\n";
        bunkStats += "Bunk 2 classes for 80% attendance\n";
        bunkStats += "Bunk 1 class for 85% attendance";

        assertEquals(bunkStats, subject.generateBunkStats(75, true));
    }

    @Test
    public void generateBunkStats_NumberOfTotalClassesIsLarge_DoesNotContainRepeatedStats() {
        Subject subject = new Subject();
        subject.attendance = 85;
        subject.theoryClassesPresent = 17;
        subject.theoryClasses = 20;

        String bunkStats = "";
        bunkStats += "Bunk 2 more classes for 75% attendance\n";
        bunkStats += "Bunk 1 more class for 80% attendance\n";
        bunkStats += "Need 10 more classes for 90% attendance";

        assertEquals(bunkStats, subject.generateBunkStats(75, true));
    }

    @Test
    public void generateBunkStats_ZeroClasses_GeneratesEmptyStats() {
        Subject subject = new Subject();

        assertEquals("", subject.generateBunkStats(75, true));
    }
}

@@ -2451,16 +2451,21 @@
 ats_Zero
+Total
 Classes_
@@ -2598,11 +2598,959 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void generateBunkStats_LessThanMinimumAttendance_GeneratesDontBunkWarning() %7B%0A        Subject subject = new Subject();%0A        subject.attendance = 10;%0A        subject.theoryClassesPresent = 1;%0A        subject.theoryClasses = 10;%0A%0A        String bunkStats = %22%22;%0A        bunkStats += %22DO NOT BUNK ANY MORE CLASSES%5Cn%22;%0A        bunkStats += %22Need 26 more classes for 75%25 attendance%5Cn%22;%0A        bunkStats += %22Need 35 more classes for 80%25 attendance%22;%0A%0A        assertEquals(bunkStats, subject.generateBunkStats(75, true));%0A    %7D%0A%0A    @Test%0A    public void generateBunkStats_ZeroAttendance_GeneratesDontBunkWarning() %7B%0A        Subject subject = new Subject();%0A        subject.attendance = 0;%0A        subject.theoryClassesPresent = 0;%0A        subject.theoryClasses = 35;%0A%0A        String bunkStats = %22%22;%0A        bunkStats += %22DO NOT BUNK ANY MORE CLASSES%22;%0A%0A        assertEquals(bunkStats, subject.generateBunkStats(75, true));%0A    %7D
 %0A%7D%0A

Add tests for less than minimum attendance for generateBunkStats()