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

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

class NotificationTest {

    @Test
    void eachObjectUsesItsOwnSend() {
        Notification email = new EmailNotification("alice@example.com", "Hola");
        Notification sms = new SmsNotification("987654321", "Hola");
        assertEquals("[correo] para alice@example.com: Hola", email.send());
        assertEquals("[SMS] al 987654321: Hola", sms.send());
    }

    @Test
    void pushUsesInheritedSend() {
        Notification push = new PushNotification("bob", "Hola");
        assertEquals("[aviso] bob: Hola", push.send());
    }

    @Test
    void overriddenCostAgreesWithInstanceofChain() {
        ArrayList<Notification> all = new ArrayList<>();
        all.add(new EmailNotification("alice@example.com", "a"));
        all.add(new SmsNotification("987654321", "b"));
        all.add(new PushNotification("bob", "c"));
        for (Notification n : all) {
            assertEquals(CostByInstanceof.cost(n), n.cost());
        }
    }
}
