Skip to content

Commit

Permalink
wrote test
Browse files Browse the repository at this point in the history
  • Loading branch information
Petrovich-A committed Jul 6, 2023
1 parent 0a9948f commit 81e63b7
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

import by.petrovich.eshop.EShopApplication;
import by.petrovich.eshop.dto.ProductDto;
import by.petrovich.eshop.entity.Cart;
import by.petrovich.eshop.entity.Product;
import by.petrovich.eshop.service.CartService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.ArrayList;
import java.util.List;

import static org.junit.jupiter.api.Assertions.assertEquals;

Expand All @@ -21,7 +24,7 @@ class CartServiceImplTest {
}

@Test
void calculateTotalPrice() {
void testCalculateTotalPrice() {
double price1 = 10.0;
double price2 = 5.55;
ProductDto productDto1 = ProductDto.builder().price(price1).build();
Expand All @@ -33,4 +36,16 @@ void calculateTotalPrice() {
double expected = 15.55;
assertEquals(expected, actual);
}

@Test
void testAddProduct() {
Product product1 = Product.builder().productId(1).name("name1").price(10.5).build();
Product product2 = Product.builder().productId(2).name("name2").price(5.0).build();
List<Product> products = new ArrayList<>();
products.add(product1);
products.add(product2);
Cart expected = new Cart();
expected.setProducts(products);

}
}

0 comments on commit 81e63b7

Please sign in to comment.