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

import org.junit.jupiter.api.Test;

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

/**
 * {@link InvoiceStatusEnum} 的单元测试
 */
public class InvoiceStatusEnumTest {

    @Test
    public void testFromType() {
        // 测试正常情况 - 可开票
        assertEquals(InvoiceStatusEnum.INVOICABLE, InvoiceStatusEnum.fromType(0));
        
        // 测试正常情况 - 待开票
        assertEquals(InvoiceStatusEnum.PENDINGINVOICING, InvoiceStatusEnum.fromType(1));
        
        // 测试正常情况 - 已开票
        assertEquals(InvoiceStatusEnum.INVOICINGSUCCESSFUL, InvoiceStatusEnum.fromType(2));
        
        // 测试正常情况 - 开票失败
        assertEquals(InvoiceStatusEnum.INVOICINGFAILED, InvoiceStatusEnum.fromType(3));
        
        // 测试不存在的类型
        assertNull(InvoiceStatusEnum.fromType(999));
        
        // 测试null值
        assertNull(InvoiceStatusEnum.fromType(null));
    }

    @Test
    public void testEnumValues() {
        // 测试枚举值的基本属性
        assertEquals(0, InvoiceStatusEnum.INVOICABLE.getCode());
        assertEquals("可开票", InvoiceStatusEnum.INVOICABLE.getDesc());
        
        assertEquals(1, InvoiceStatusEnum.PENDINGINVOICING.getCode());
        assertEquals("待开票", InvoiceStatusEnum.PENDINGINVOICING.getDesc());
        
        assertEquals(2, InvoiceStatusEnum.INVOICINGSUCCESSFUL.getCode());
        assertEquals("已开票", InvoiceStatusEnum.INVOICINGSUCCESSFUL.getDesc());
        
        assertEquals(3, InvoiceStatusEnum.INVOICINGFAILED.getCode());
        assertEquals("开票失败", InvoiceStatusEnum.INVOICINGFAILED.getDesc());
    }
}