package com.cf.imes.module.system.enums.advertisement;

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;

/**
 * {@link AdvertisementPositionEnum} 的单元测试
 */
class AdvertisementPositionEnumTest {

    @Test
    void testEnumValues() {
        // 测试枚举值是否正确
        assertEquals(1, AdvertisementPositionEnum.WORKBENCH_CAROUSEL.getStatus());
        assertEquals("首页工作台轮播", AdvertisementPositionEnum.WORKBENCH_CAROUSEL.getName());

        assertEquals(2, AdvertisementPositionEnum.SYSTEMCONFIG_AMOUNTQUERY_CAROUSEL.getStatus());
        assertEquals("系统管理余额查询轮播", AdvertisementPositionEnum.SYSTEMCONFIG_AMOUNTQUERY_CAROUSEL.getName());

        assertEquals(3, AdvertisementPositionEnum.BASECONFIG_FUNDSQUERY_CAROUSEL.getStatus());
        assertEquals("基础配置资金查询轮播", AdvertisementPositionEnum.BASECONFIG_FUNDSQUERY_CAROUSEL.getName());
    }

    @Test
    void testArrays() {
        // 测试 ARRAYS 是否包含所有枚举值的状态
        int[] arrays = AdvertisementPositionEnum.ARRAYS;
        assertEquals(3, arrays.length);
        assertTrue(contains(arrays, 1)); // WORKBENCH_CAROUSEL
        assertTrue(contains(arrays, 2)); // SYSTEMCONFIG_AMOUNTQUERY_CAROUSEL
        assertTrue(contains(arrays, 3)); // BASECONFIG_FUNDSQUERY_CAROUSEL
    }

    @Test
    void testArrayMethod() {
        // 测试array()方法
        int[] arrays = AdvertisementPositionEnum.WORKBENCH_CAROUSEL.array();
        assertEquals(3, arrays.length);
        assertTrue(contains(arrays, 1)); // WORKBENCH_CAROUSEL
        assertTrue(contains(arrays, 2)); // SYSTEMCONFIG_AMOUNTQUERY_CAROUSEL
        assertTrue(contains(arrays, 3)); // BASECONFIG_FUNDSQUERY_CAROUSEL
    }

    /**
     * 辅助方法：检查数组中是否包含指定元素
     *
     * @param array 数组
     * @param value 值
     * @return 是否包含
     */
    private boolean contains(int[] array, int value) {
        for (int item : array) {
            if (item == value) {
                return true;
            }
        }
        return false;
    }
}