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

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.math.BigDecimal;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

/**
 * SYJC-UT-001、007～009
 */
@DisplayName("LabDetectionRules")
class LabDetectionRulesTest
{

    @Test
    @DisplayName("SYJC-UT-001 样本来源枚举")
    void ut001_sampleSource()
    {
        assertTrue(LabDetectionRules.isSampleSourceValid(1));
        assertTrue(LabDetectionRules.isSampleSourceValid(4));
        assertFalse(LabDetectionRules.isSampleSourceValid(0));
        assertFalse(LabDetectionRules.isSampleSourceValid(5));
    }

    @Test
    @DisplayName("SYJC-UT-003 检测量非负整数")
    void ut003_testQuantity()
    {
        assertTrue(LabDetectionRules.isNonNegativeInteger(0));
        assertTrue(LabDetectionRules.isNonNegativeInteger(100));
        assertFalse(LabDetectionRules.isNonNegativeInteger(-1));
        assertFalse(LabDetectionRules.isNonNegativeInteger(null));
    }

    @Test
    @DisplayName("SYJC-UT-004 阳性数非负整数")
    void ut004_positiveCount()
    {
        assertTrue(LabDetectionRules.isNonNegativeInteger(0));
        assertTrue(LabDetectionRules.isNonNegativeInteger(10));
        assertFalse(LabDetectionRules.isNonNegativeInteger(-1));
        assertFalse(LabDetectionRules.isNonNegativeInteger(null));
    }

    @Test
    @DisplayName("SYJC-UT-007 检出率常规比值")
    void ut007_calcRate()
    {
        assertEquals(new BigDecimal("0.1200"), LabDetectionRules.calcDetectionRate(100, 12));
    }

    @Test
    @DisplayName("SYJC-UT-008 零检测量检出率")
    void ut008_calcRateZeroQuantity()
    {
        assertEquals(new BigDecimal("0.0000"), LabDetectionRules.calcDetectionRate(0, 0));
    }

    @Test
    @DisplayName("SYJC-UT-009 全阴性检出率")
    void ut009_calcRateAllNegative()
    {
        assertEquals(new BigDecimal("0.0000"), LabDetectionRules.calcDetectionRate(50, 0));
    }
}
