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

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.when;

import com.ruoyi.web.modules.trading.mapper.BizSupplierSettlementMapper;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;

@ExtendWith(MockitoExtension.class)
@DisplayName("SupplierReferenceChecker")
class SupplierReferenceCheckerTest
{
    @Mock
    private BizSupplierSettlementMapper bizSupplierSettlementMapper;

    @InjectMocks
    private SupplierReferenceChecker checker;

    @Test
    @DisplayName("有待结算单")
    void hasUnsettledSettlementTrue()
    {
        when(bizSupplierSettlementMapper.countPendingBySupplierId(1L)).thenReturn(1L);
        assertTrue(checker.hasUnsettledSettlement(1L));
        assertTrue(checker.hasReference(1L));
    }

    @Test
    @DisplayName("无待结算单")
    void hasUnsettledSettlementFalse()
    {
        when(bizSupplierSettlementMapper.countPendingBySupplierId(1L)).thenReturn(0L);
        assertFalse(checker.hasUnsettledSettlement(1L));
    }
}
