5
5
6
6
import com .wonu606 .calculator .model .CalculationResult ;
7
7
import com .wonu606 .calculator .storage .Persistence ;
8
+ import com .wonu606 .calculator .storage .ResultStore ;
9
+ import com .wonu606 .util .Message ;
8
10
import java .util .ArrayList ;
9
11
import java .util .List ;
10
12
import org .junit .jupiter .api .BeforeEach ;
11
13
import org .junit .jupiter .api .DisplayName ;
12
14
import org .junit .jupiter .api .Test ;
13
15
14
16
public class ResultStoreTest {
15
-
16
17
@ Test
17
18
@ DisplayName ("저장" )
18
19
void testSave () {
19
20
// given
20
- Persistence store ;
21
+ Persistence store = new ResultStore () ;
21
22
22
23
// when
23
24
CalculationResult calculationResult = new CalculationResult ("2 + 2" , 4.0d );
@@ -31,7 +32,7 @@ void testSave() {
31
32
@ DisplayName ("순서로 결과 찾기" )
32
33
void testFind () {
33
34
// given
34
- Persistence store ;
35
+ Persistence store = new ResultStore () ;
35
36
36
37
// when
37
38
CalculationResult saveResult = new CalculationResult ("5 + 10" , 15.0d );
@@ -46,7 +47,7 @@ void testFind() {
46
47
@ DisplayName ("1 미만의 수로 찾은 경우 예외 발생" )
47
48
void testFindNumberLessThan1 () {
48
49
// given
49
- Persistence store ;
50
+ Persistence store = new ResultStore () ;
50
51
51
52
// then
52
53
CalculationResult saveResult = new CalculationResult ("5 + 10" , 15.0d );
@@ -55,14 +56,14 @@ void testFindNumberLessThan1() {
55
56
// then
56
57
assertThatThrownBy (() -> store .findResult (0 ))
57
58
.isInstanceOf (IllegalArgumentException .class )
58
- .hasMessageContaining ("잘못된 순번입니다." );
59
+ .hasMessageContaining (Message . INVALID_ORDER );
59
60
}
60
61
61
62
@ Test
62
63
@ DisplayName ("사이즈 초과의 수로 찾은 경우 예외 발생" )
63
64
void testFindNumberMoreThanSize () {
64
65
// given
65
- Persistence store ;
66
+ Persistence store = new ResultStore () ;
66
67
67
68
// when
68
69
CalculationResult saveResult = new CalculationResult ("5 + 10" , 15.0d );
@@ -71,14 +72,14 @@ void testFindNumberMoreThanSize() {
71
72
// then
72
73
assertThatThrownBy (() -> store .findResult (store .findAllResult ().size () + 1 ))
73
74
.isInstanceOf (IllegalArgumentException .class )
74
- .hasMessageContaining ("잘못된 순번입니다." );
75
+ .hasMessageContaining (Message . INVALID_ORDER );
75
76
}
76
77
77
78
@ Test
78
79
@ DisplayName ("모두 찾기" )
79
80
void testFindAll () {
80
81
// given
81
- Persistence store ;
82
+ Persistence store = new ResultStore () ;
82
83
83
84
// when
84
85
List <CalculationResult > results = new ArrayList <>();
@@ -100,7 +101,7 @@ void testFindAll() {
100
101
@ DisplayName ("클리어" )
101
102
void testClear () {
102
103
// given
103
- Persistence store ;
104
+ Persistence store = new ResultStore () ;
104
105
105
106
// when
106
107
store .saveResult (new CalculationResult ("11 + 6" , 17.0d ));
0 commit comments