package com.livingworld.data.saved;

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

import org.junit.jupiter.api.Test;

class SaveMetadataTest {

    @Test
    void acceptsVersionedChronologicalMetadata() {
        SaveMetadata metadata = new SaveMetadata(1, "0.1.0", 100L, 200L);

        assertEquals(1, metadata.schemaVersion());
        assertEquals("0.1.0", metadata.modVersion());
        assertEquals(100L, metadata.createdAt());
        assertEquals(200L, metadata.updatedAt());
    }

    @Test
    void rejectsInvalidSchemaVersion() {
        assertThrows(
                IllegalArgumentException.class,
                () -> new SaveMetadata(0, "0.1.0", 100L, 100L));
    }

    @Test
    void rejectsBlankModVersion() {
        assertThrows(
                IllegalArgumentException.class,
                () -> new SaveMetadata(1, " ", 100L, 100L));
    }

    @Test
    void rejectsUpdateBeforeCreation() {
        assertThrows(
                IllegalArgumentException.class,
                () -> new SaveMetadata(1, "0.1.0", 200L, 100L));
    }
}
