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

import org.junit.jupiter.api.Test;

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

/**
 * {@link PayOrderStatusEnum} 的单元测试
 */
public class PayOrderStatusEnumTest {

    @Test
    public void testFromType() {
        // 测试正常情况 - 等待支付
        assertEquals(PayOrderStatusEnum.WAITING, PayOrderStatusEnum.fromType(0));
        
        // 测试正常情况 - 支付成功
        assertEquals(PayOrderStatusEnum.SUCCESS, PayOrderStatusEnum.fromType(10));
        
        // 测试正常情况 - 已退款
        assertEquals(PayOrderStatusEnum.REFUND, PayOrderStatusEnum.fromType(20));
        
        // 测试正常情况 - 支付关闭
        assertEquals(PayOrderStatusEnum.CLOSED, PayOrderStatusEnum.fromType(30));
        
        // 测试不存在的类型
        assertNull(PayOrderStatusEnum.fromType(999));
        
        // 测试null值
        assertNull(PayOrderStatusEnum.fromType(null));
    }

    @Test
    public void testIsSuccess() {
        // 测试支付成功的状态
        assertTrue(PayOrderStatusEnum.isSuccess(10));
        
        // 测试非支付成功的状态
        assertFalse(PayOrderStatusEnum.isSuccess(0));
        assertFalse(PayOrderStatusEnum.isSuccess(20));
        assertFalse(PayOrderStatusEnum.isSuccess(30));
        
        // 测试null值
        assertFalse(PayOrderStatusEnum.isSuccess(null));
    }

    @Test
    public void testIsClosed() {
        // 测试支付关闭的状态
        assertTrue(PayOrderStatusEnum.isClosed(30));
        
        // 测试非支付关闭的状态
        assertFalse(PayOrderStatusEnum.isClosed(0));
        assertFalse(PayOrderStatusEnum.isClosed(10));
        assertFalse(PayOrderStatusEnum.isClosed(20));
        
        // 测试null值
        assertFalse(PayOrderStatusEnum.isClosed(null));
    }

    @Test
    public void testEnumValues() {
        // 测试枚举值的基本属性
        assertEquals(0, PayOrderStatusEnum.WAITING.getStatus());
        assertEquals(10, PayOrderStatusEnum.SUCCESS.getStatus());
        assertEquals(20, PayOrderStatusEnum.REFUND.getStatus());
        assertEquals(30, PayOrderStatusEnum.CLOSED.getStatus());
    }
}