package thb.jeanluc.adventure.model;

import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;

class CombinationTest {

    @Test
    void keyIsOrderIndependentAndSorted() {
        assertThat(Combination.key("matches", "torch"))
                .isEqualTo(Combination.key("torch", "matches"))
                .isEqualTo("matches|torch");
        assertThat(Combination.key("b", "a")).isEqualTo("a|b");
    }

    @Test
    void nullCollectionComponentsBecomeEmpty() {
        Combination c = new Combination("a", "b", null, null, null, null, "ok", null);
        assertThat(c.requires()).isEmpty();
        assertThat(c.consume()).isEmpty();
        assertThat(c.effects()).isEmpty();
        assertThat(c.produce()).isNull();
        assertThat(c.key()).isEqualTo("a|b");
    }
}
