-
Notifications
You must be signed in to change notification settings - Fork 151
Expand file tree
/
Copy pathMemoryCalcResultRecordRepositoryTest.java
More file actions
42 lines (33 loc) · 1.25 KB
/
MemoryCalcResultRecordRepositoryTest.java
File metadata and controls
42 lines (33 loc) · 1.25 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
package calcproject.repository;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import calcproject.models.CalcResultRecordModel;
class MemoryCalcResultRecordRepositoryTest {
private CalcResultRecordRepository calcResultRecordRepository;
@BeforeEach
void beforeEach() {
Map<Integer, CalcResultRecordModel> calcMap = new HashMap<>();
int startIdx = 0;
this.calcResultRecordRepository =
new MemoryCalcResultRecordRepository(calcMap, startIdx);
}
@Test
void testLoadCalcRecords() {
// given
CalcResultRecordModel calcRecord1 = new CalcResultRecordModel("2+2", 4);
CalcResultRecordModel calcRecord2 = new CalcResultRecordModel("3+3", 6);
calcResultRecordRepository.saveCalcResultRecord(calcRecord1);
calcResultRecordRepository.saveCalcResultRecord(calcRecord2);
// when
List<CalcResultRecordModel> resultCalcRecords = calcResultRecordRepository.loadCalcResultRecords();
List<CalcResultRecordModel> expectedCalcRecords = Arrays.asList(calcRecord1, calcRecord2);
// then
Assertions.assertThat(resultCalcRecords)
.containsExactlyInAnyOrderElementsOf(expectedCalcRecords);
}
}