package ca.recrown.islandsurvivalcraft.caching;

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

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.TestInstance.Lifecycle;

@TestInstance(Lifecycle.PER_CLASS)
public class CoordinateIdentifierTest {
    Cache<Integer> integerCache;

    @BeforeAll
    public void setUp() {
        integerCache = new Cache<>(4);
    }

    @AfterEach
    public void cleanUp() {
        integerCache.clearCache();
    }

    @Test
    public void testIdentityChecking() {
        integerCache.retrieveCache(new CoordinateIdentifier(1, 2)).setValue(8);
        integerCache.retrieveCache(new CoordinateIdentifier(1, 2)).setValue(4);

        assertEquals(4, integerCache.retrieveCache(new CoordinateIdentifier(1, 2)).getValue());
    }
}