package com.ruoyi.web.modules.goods.facade;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.when;
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;
import com.ruoyi.web.modules.goods.facade.impl.GoodsFacadeImpl;
import com.ruoyi.web.modules.goods.mapper.BizGoodsMapper;

@ExtendWith(MockitoExtension.class)
class GoodsFacadeImplTest
{
    @Mock
    private BizGoodsMapper goodsMapper;

    @InjectMocks
    private GoodsFacadeImpl goodsFacade;

    @Test
    void hasBlockingGoodsForShopDelete_true()
    {
        when(goodsMapper.countBlockingByShopId(1L)).thenReturn(2);
        assertTrue(goodsFacade.hasBlockingGoodsForShopDelete(1L));
    }

    @Test
    void hasBlockingGoodsForShopDelete_false()
    {
        when(goodsMapper.countBlockingByShopId(1L)).thenReturn(0);
        assertFalse(goodsFacade.hasBlockingGoodsForShopDelete(1L));
    }

    @Test
    void existsByCategoryId_true()
    {
        when(goodsMapper.countByCategoryId(10L)).thenReturn(1);
        assertTrue(goodsFacade.existsByCategoryId(10L));
    }

    @Test
    void existsByCategoryId_false()
    {
        when(goodsMapper.countByCategoryId(10L)).thenReturn(0);
        assertFalse(goodsFacade.existsByCategoryId(10L));
    }

    @Test
    void existsByShopCategoryId_true()
    {
        when(goodsMapper.countByShopCategoryId(1L)).thenReturn(1);
        assertTrue(goodsFacade.existsByShopCategoryId(1L));
    }

    @Test
    void existsByShopCategoryId_false()
    {
        when(goodsMapper.countByShopCategoryId(1L)).thenReturn(0);
        assertFalse(goodsFacade.existsByShopCategoryId(1L));
    }
}
