-
Notifications
You must be signed in to change notification settings - Fork 109
Expand file tree
/
Copy pathBasketTest.java
More file actions
58 lines (44 loc) · 1.5 KB
/
BasketTest.java
File metadata and controls
58 lines (44 loc) · 1.5 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
57
58
package com.booleanuk.core;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
class BasketTest {
@Test
public void testAddBagelAddsBagelToBasket() {
Basket basket = new Basket();
basket.addBagel("normal", 1);
Assertions.assertFalse(basket.items.isEmpty());
}
@Test
public void testRemoveBagelRemovesBagelFromBasket() {
Basket basket = new Basket();
basket.addBagel("normal", 1);
// Then we remove the bagel.
basket.removeBagel("normal");
Assertions.assertTrue(basket.items.isEmpty());
}
@Test
public void testHasCapacity() {
Basket basket = new Basket();
basket.addBagel("normal", 1);
basket.addBagel("special", 2);
// Check if it returns true when not full.
boolean hasMoreSpace = basket.hasCapacity();
Assertions.assertTrue(hasMoreSpace);
// Check if it returns false when full.
basket.addBagel("tasteless", 3);
Assertions.assertFalse(basket.hasCapacity());
}
@Test
public void changeBasketCapacity() {
Basket basket = new Basket();
basket.changeBasketCapacity(10);
Assertions.assertEquals(10, basket.max);
}
@Test
public void testRemoveBagelFromBasketIndicatesIfItemExists() {
Basket basket = new Basket();
basket.addBagel("normal", 1);
boolean itemDoesNotExists = basket.removeBagel("special");
Assertions.assertFalse(itemDoesNotExists);
}
}