55
66import com .wonu606 .calculator .model .CalculationResult ;
77import com .wonu606 .calculator .storage .Persistence ;
8+ import com .wonu606 .calculator .storage .ResultStore ;
9+ import com .wonu606 .util .Message ;
810import java .util .ArrayList ;
911import java .util .List ;
1012import org .junit .jupiter .api .BeforeEach ;
1113import org .junit .jupiter .api .DisplayName ;
1214import org .junit .jupiter .api .Test ;
1315
1416public class ResultStoreTest {
15-
1617 @ Test
1718 @ DisplayName ("저장" )
1819 void testSave () {
1920 // given
20- Persistence store ;
21+ Persistence store = new ResultStore () ;
2122
2223 // when
2324 CalculationResult calculationResult = new CalculationResult ("2 + 2" , 4.0d );
@@ -31,7 +32,7 @@ void testSave() {
3132 @ DisplayName ("순서로 결과 찾기" )
3233 void testFind () {
3334 // given
34- Persistence store ;
35+ Persistence store = new ResultStore () ;
3536
3637 // when
3738 CalculationResult saveResult = new CalculationResult ("5 + 10" , 15.0d );
@@ -46,7 +47,7 @@ void testFind() {
4647 @ DisplayName ("1 미만의 수로 찾은 경우 예외 발생" )
4748 void testFindNumberLessThan1 () {
4849 // given
49- Persistence store ;
50+ Persistence store = new ResultStore () ;
5051
5152 // then
5253 CalculationResult saveResult = new CalculationResult ("5 + 10" , 15.0d );
@@ -55,14 +56,14 @@ void testFindNumberLessThan1() {
5556 // then
5657 assertThatThrownBy (() -> store .findResult (0 ))
5758 .isInstanceOf (IllegalArgumentException .class )
58- .hasMessageContaining ("잘못된 순번입니다." );
59+ .hasMessageContaining (Message . INVALID_ORDER );
5960 }
6061
6162 @ Test
6263 @ DisplayName ("사이즈 초과의 수로 찾은 경우 예외 발생" )
6364 void testFindNumberMoreThanSize () {
6465 // given
65- Persistence store ;
66+ Persistence store = new ResultStore () ;
6667
6768 // when
6869 CalculationResult saveResult = new CalculationResult ("5 + 10" , 15.0d );
@@ -71,14 +72,14 @@ void testFindNumberMoreThanSize() {
7172 // then
7273 assertThatThrownBy (() -> store .findResult (store .findAllResult ().size () + 1 ))
7374 .isInstanceOf (IllegalArgumentException .class )
74- .hasMessageContaining ("잘못된 순번입니다." );
75+ .hasMessageContaining (Message . INVALID_ORDER );
7576 }
7677
7778 @ Test
7879 @ DisplayName ("모두 찾기" )
7980 void testFindAll () {
8081 // given
81- Persistence store ;
82+ Persistence store = new ResultStore () ;
8283
8384 // when
8485 List <CalculationResult > results = new ArrayList <>();
@@ -100,7 +101,7 @@ void testFindAll() {
100101 @ DisplayName ("클리어" )
101102 void testClear () {
102103 // given
103- Persistence store ;
104+ Persistence store = new ResultStore () ;
104105
105106 // when
106107 store .saveResult (new CalculationResult ("11 + 6" , 17.0d ));
0 commit comments