package com.ruoyi.web.modules.trading.support;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

import java.util.Arrays;
import com.ruoyi.common.exception.ServiceException;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

@DisplayName("ChangeFactorsCodec")
class ChangeFactorsCodecTest
{
    @Test
    @DisplayName("去重排序入库")
    void encode()
    {
        assertEquals("1,3", ChangeFactorsCodec.encode(Arrays.asList(3, 1, 1)));
    }

    @Test
    @DisplayName("空列表")
    void empty()
    {
        assertThrows(ServiceException.class, () -> ChangeFactorsCodec.encode(Arrays.asList()));
    }

    @Test
    @DisplayName("非法码")
    void invalid()
    {
        assertThrows(ServiceException.class, () -> ChangeFactorsCodec.encode(Arrays.asList(9)));
    }
}
