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

/**
 * GTFY-XM-UT-001～004、011、013
 */
@DisplayName("CommonProsperityProjectRules")
class CommonProsperityProjectRulesTest
{

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

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

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

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

    @Test
    @DisplayName("GTFY-XM-UT-011 运营图后缀")
    void ut011_opImageExt()
    {
        assertTrue(CommonProsperityProjectRules.isOperationImageExtensionAllowed("a.jpg"));
        assertFalse(CommonProsperityProjectRules.isOperationImageExtensionAllowed("a.bmp"));
    }

    @Test
    @DisplayName("GTFY-XM-UT-013 视频后缀")
    void ut013_videoExt()
    {
        assertTrue(CommonProsperityProjectRules.isVideoExtensionAllowed("v.mp4"));
        assertFalse(CommonProsperityProjectRules.isVideoExtensionAllowed("v.avi"));
    }
}
