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

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

/**
 * {@link AdvertisementStatusEnum} 的单元测试
 */
class AdvertisementStatusEnumTest {

    @Test
    void testEnumValues() {
        // 测试枚举值是否正确
        assertEquals(0, AdvertisementStatusEnum.UNPUBLISHED.getStatus());
        assertEquals("未发布", AdvertisementStatusEnum.UNPUBLISHED.getName());

        assertEquals(1, AdvertisementStatusEnum.PUBLISHED.getStatus());
        assertEquals("已发布", AdvertisementStatusEnum.PUBLISHED.getName());

        assertEquals(2, AdvertisementStatusEnum.ENDED.getStatus());
        assertEquals("已结束", AdvertisementStatusEnum.ENDED.getName());
    }

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

    @Test
    void testArrayMethod() {
        // 测试array()方法
        int[] arrays = AdvertisementStatusEnum.UNPUBLISHED.array();
        assertEquals(3, arrays.length);
        assertTrue(contains(arrays, 0)); // UNPUBLISHED
        assertTrue(contains(arrays, 1)); // PUBLISHED
        assertTrue(contains(arrays, 2)); // ENDED
    }

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