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

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

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;

/**
 * KJXM-UT-001、007～008
 */
@DisplayName("TechProjectGuideRules")
class TechProjectGuideRulesTest
{

    @ParameterizedTest
    @CsvSource({ "0, true", "1, false" })
    @DisplayName("KJXM-UT-009 已发布禁止修改")
    void ut009_canEdit(int status, boolean expected)
    {
        assertEquals(expected, TechProjectGuideRules.canEdit(status));
    }

    @ParameterizedTest
    @CsvSource({ "0, true", "1, false" })
    @DisplayName("KJXM-UT-010 已发布禁止删除")
    void ut010_canDelete(int status, boolean expected)
    {
        assertEquals(expected, TechProjectGuideRules.canDelete(status));
    }

    @ParameterizedTest
    @CsvSource({ "0, false", "1, true" })
    @DisplayName("KJXM-UT-011 未发布禁止下架")
    void ut011_canOffline(int status, boolean expected)
    {
        assertEquals(expected, TechProjectGuideRules.canOffline(status));
    }

    @Test
    @DisplayName("KJXM-UT-007 附件后缀白名单")
    void ut007_attachmentExt()
    {
        assertTrue(TechProjectGuideRules.isAttachmentExtensionAllowed("a.pdf"));
        assertFalse(TechProjectGuideRules.isAttachmentExtensionAllowed("a.exe"));
    }

    @Test
    @DisplayName("KJXM-UT-008 封面后缀")
    void ut008_coverExt()
    {
        assertTrue(TechProjectGuideRules.isCoverExtensionAllowed("a.png"));
        assertFalse(TechProjectGuideRules.isCoverExtensionAllowed("a.pdf"));
    }
}
