package com.ruoyi.web.modules.store.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.store.constant.ShopConstants;
import com.ruoyi.web.modules.store.domain.BizShop;
import com.ruoyi.web.modules.store.facade.impl.ShopFacadeImpl;
import com.ruoyi.web.modules.store.mapper.BizShopMapper;

@ExtendWith(MockitoExtension.class)
class ShopFacadeImplTest
{
    @Mock
    private BizShopMapper shopMapper;

    @InjectMocks
    private ShopFacadeImpl shopFacade;

    @Test
    void isShopOpenForOrder_closed_returnsFalse()
    {
        BizShop shop = new BizShop();
        shop.setShopStatus(ShopConstants.STATUS_CLOSED);
        when(shopMapper.selectById(1L)).thenReturn(shop);

        assertFalse(shopFacade.isShopOpenForOrder(1L));
    }

    @Test
    void isShopOpenForOrder_open_returnsTrue()
    {
        BizShop shop = new BizShop();
        shop.setShopStatus(ShopConstants.STATUS_OPEN);
        when(shopMapper.selectById(1L)).thenReturn(shop);

        assertTrue(shopFacade.isShopOpenForOrder(1L));
    }

    @Test
    void isShopOpenForOrder_deleted_returnsFalse()
    {
        when(shopMapper.selectById(1L)).thenReturn(null);

        assertFalse(shopFacade.isShopOpenForOrder(1L));
    }
}
