package com.izouma.dingdong.service;

import com.izouma.dingdong.domain.OrderGoodsSpec;
import com.izouma.dingdong.repo.OrderGoodsSpecRepo;
import com.izouma.dingdong.repo.user.ShoppingCartRepo;
import com.izouma.dingdong.service.user.ShoppingCartService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

@SpringBootTest
@RunWith(SpringRunner.class)
public class ShoppingCartServiceTest {

    @Autowired
    private ShoppingCartService shoppingCartService;

    @Autowired
    private ShoppingCartRepo shoppingCartRepo;
    @Autowired
    private OrderGoodsSpecService orderGoodsSpecService;

    @Autowired
    private OrderGoodsSpecRepo orderGoodsSpecRepo;

    @Test
    public void testCart() {
        OrderGoodsSpec add = orderGoodsSpecService.add(1258L, null, 1);

        // OrderGoodsSpec add = orderGoodsSpecRepo.findById(1318L).orElse(null);

        System.out.println(shoppingCartService.save(83L, add));
    }

    @Test
    public void test() {
        System.out.println(shoppingCartRepo.findById(1484L).orElse(null));
    }

    @Test
    public void testSub(){
        OrderGoodsSpec add = orderGoodsSpecService.add(607L, null, 1);
        System.out.println(shoppingCartService.add(83L, add));
        //System.out.println(shoppingCartService.sub(1500L, 83L));
    }
}
