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.math.BigDecimal;
import com.ruoyi.common.exception.ServiceException;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

@DisplayName("AvgPriceCalculator")
class AvgPriceCalculatorTest
{
    @Test
    @DisplayName("均价公式")
    void calc()
    {
        assertEquals(new BigDecimal("12.00"),
                AvgPriceCalculator.calculate(new BigDecimal("10"), new BigDecimal("14")));
    }

    @Test
    @DisplayName("最低价大于最高价")
    void invalidRange()
    {
        assertThrows(ServiceException.class,
                () -> AvgPriceCalculator.calculate(new BigDecimal("15"), new BigDecimal("10")));
    }
}
