-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathUnitTestSeller.java
More file actions
56 lines (49 loc) · 1.48 KB
/
UnitTestSeller.java
File metadata and controls
56 lines (49 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class UnitTestSeller {
private Seller seller;
private Product product;
@BeforeEach
void SellersetUp() throws InvalidPriceException, InvalidStockException {
seller =
new Seller(
"S001",
"Matthew Yeh",
"669-231-9366",
"917 Tassasara Drive",
"Matty's Melons",
"password123");
product = new Product("P001", "Watermelon", "Fruit", 25, 3.99);
}
@Test
void testSellerGetters() {
assertEquals("S001", seller.getUserID());
assertEquals("Matthew Yeh", seller.getName());
assertEquals("Matty's Melons", seller.getStoreName());
}
@Test
void testAddProduct() {
seller.addProduct(product);
assertTrue(seller.getproductMap().containsKey("P001"));
assertEquals(product, seller.getproductMap().get("P001"));
}
@Test
void testRemoveProduct() {
seller.addProduct(product);
seller.removeProduct("P001");
assertFalse(seller.getproductMap().containsKey("P001"));
}
@Test
void testHasProduct() {
seller.addProduct(product);
assertTrue(seller.hasProduct("P001"));
assertFalse(seller.hasProduct("P002"));
}
@Test
void testChangeProductPrice() throws InvalidPriceException {
seller.addProduct(product);
seller.changeProductPrice("P001", 4.99);
assertEquals(4.99, seller.getproductMap().get("P001").getPrice());
}
}