package com.ruoyi.web.modules.industrypolicy.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;

/**
 * ZCZX-XC-UT-001～004、009～010
 */
@DisplayName("IndustryPolicyPublicityRules")
class IndustryPolicyPublicityRulesTest
{

    @Test
    @DisplayName("ZCZX-XC-UT-001 仅未发布可编辑")
    void ut001_canEdit()
    {
        assertTrue(IndustryPolicyPublicityRules.canEdit(0));
        assertFalse(IndustryPolicyPublicityRules.canEdit(1));
    }

    @Test
    @DisplayName("ZCZX-XC-UT-002 仅未发布可删")
    void ut002_canDelete()
    {
        assertTrue(IndustryPolicyPublicityRules.canDelete(0));
        assertFalse(IndustryPolicyPublicityRules.canDelete(1));
    }

    @ParameterizedTest
    @CsvSource({ "0, true", "1, false" })
    @DisplayName("ZCZX-XC-UT-003 发布守卫")
    void ut003_canPublish(int status, boolean expected)
    {
        assertEquals(expected, IndustryPolicyPublicityRules.canPublish(status));
    }

    @ParameterizedTest
    @CsvSource({ "1, true", "0, false" })
    @DisplayName("ZCZX-XC-UT-004 下架守卫")
    void ut004_canOffline(int status, boolean expected)
    {
        assertEquals(expected, IndustryPolicyPublicityRules.canOffline(status));
    }

    @Test
    @DisplayName("ZCZX-XC-UT-009 政策文件后缀")
    void ut009_policyFileExt()
    {
        assertTrue(IndustryPolicyPublicityRules.isPolicyFileExtensionAllowed("a.pdf"));
        assertFalse(IndustryPolicyPublicityRules.isPolicyFileExtensionAllowed("a.exe"));
    }

    @Test
    @DisplayName("ZCZX-XC-UT-010 封面后缀")
    void ut010_coverExt()
    {
        assertTrue(IndustryPolicyPublicityRules.isCoverExtensionAllowed("c.jpg"));
        assertFalse(IndustryPolicyPublicityRules.isCoverExtensionAllowed("c.bmp"));
    }
}
