import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.List;
import org.junit.jupiter.api.Test;

class EmployeeTest {

    @Test
    void salariedPaysFixedSalary() {
        Employee e = new SalariedEmployee("alice", 350_000);
        assertEquals(350_000, e.monthlyPay());
    }

    @Test
    void hourlyPaysRateTimesHours() {
        Employee e = new HourlyEmployee("bob", 1_250, 96);
        assertEquals(120_000, e.monthlyPay());
    }

    @Test
    void payslipUsesTheSubclassPay() {
        Employee e = new SalariedEmployee("alice", 350_000);
        assertEquals("alice: S/ 3500.00", e.payslip());
    }

    @Test
    void hourlyPayslipAddsHours() {
        Employee e = new HourlyEmployee("bob", 1_250, 96);
        assertEquals("bob: S/ 1200.00 (96 h)", e.payslip());
    }

    @Test
    void totalOverAListOfEmployees() {
        List<Employee> staff = List.of(
                new SalariedEmployee("alice", 350_000),
                new HourlyEmployee("bob", 1_250, 96));
        long total = 0;
        for (Employee e : staff) {
            total += e.monthlyPay();
        }
        assertEquals(470_000, total);
    }
}
