package com.ruoyi.web.modules.trading.support;

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

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

@DisplayName("ReleaseDateCalculator")
class ReleaseDateCalculatorTest
{
    @Test
    @DisplayName("自然日相加")
    void calc() throws ParseException
    {
        Date entry = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("2026-05-20 10:00:00");
        Date expected = new SimpleDateFormat("yyyy-MM-dd").parse("2026-05-27");
        assertEquals(expected, ReleaseDateCalculator.calculate(entry, 7));
    }

    @Test
    @DisplayName("跨月")
    void crossMonth() throws ParseException
    {
        Date entry = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("2026-05-28 08:00:00");
        Date expected = new SimpleDateFormat("yyyy-MM-dd").parse("2026-06-02");
        assertEquals(expected, ReleaseDateCalculator.calculate(entry, 5));
    }
}
