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.BizTradeOrderMapper;
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("DistributorReferenceChecker")
class DistributorReferenceCheckerTest
{
    @Mock
    private BizTradeOrderMapper bizTradeOrderMapper;

    @InjectMocks
    private DistributorReferenceChecker checker;

    @Test
    @DisplayName("有待支付订单")
    void hasUnpaidOrderTrue()
    {
        when(bizTradeOrderMapper.countPendingByDistributorId(1L)).thenReturn(2L);
        assertTrue(checker.hasUnpaidOrder(1L));
        assertTrue(checker.hasReference(1L));
    }

    @Test
    @DisplayName("无待支付订单")
    void hasUnpaidOrderFalse()
    {
        when(bizTradeOrderMapper.countPendingByDistributorId(1L)).thenReturn(0L);
        assertFalse(checker.hasUnpaidOrder(1L));
    }
}
