|
1 | 1 | package tasmod.playback.filecommands;
|
2 | 2 |
|
3 | 3 | import static org.junit.jupiter.api.Assertions.assertEquals;
|
| 4 | +import static org.junit.jupiter.api.Assertions.assertIterableEquals; |
4 | 5 |
|
5 | 6 | import org.junit.jupiter.api.AfterEach;
|
6 | 7 | import org.junit.jupiter.api.BeforeEach;
|
@@ -160,4 +161,73 @@ void testMultiInlineDeserialisation() {
|
160 | 161 |
|
161 | 162 | assertEquals(expected, actual);
|
162 | 163 | }
|
| 164 | + |
| 165 | + @Test |
| 166 | + void testInlineSerialisation() { |
| 167 | + // Actual |
| 168 | + SortedFileCommandContainer container = new SortedFileCommandContainer(); |
| 169 | + container.add("test", new PlaybackFileCommand("test")); |
| 170 | + |
| 171 | + test.getInlineStorage().add(container); |
| 172 | + |
| 173 | + UnsortedFileCommandContainer actual = TASmodAPIRegistry.PLAYBACK_FILE_COMMAND.handleOnSerialiseInline(0, null); |
| 174 | + |
| 175 | + // Expected |
| 176 | + UnsortedFileCommandContainer expected = new UnsortedFileCommandContainer(); |
| 177 | + FileCommandsInCommentList commentList = new FileCommandsInCommentList(); |
| 178 | + |
| 179 | + commentList.add(new PlaybackFileCommand("test")); |
| 180 | + expected.add(commentList); |
| 181 | + |
| 182 | + assertIterableEquals(expected, actual); |
| 183 | + } |
| 184 | + |
| 185 | + @Test |
| 186 | + void testEndlineSerialisation() { |
| 187 | + // Actual |
| 188 | + SortedFileCommandContainer container = new SortedFileCommandContainer(); |
| 189 | + container.add("test", new PlaybackFileCommand("test")); |
| 190 | + |
| 191 | + test.getEndlineStorage().add(container); |
| 192 | + |
| 193 | + UnsortedFileCommandContainer actual = TASmodAPIRegistry.PLAYBACK_FILE_COMMAND.handleOnSerialiseEndline(0, null); |
| 194 | + |
| 195 | + // Expected |
| 196 | + UnsortedFileCommandContainer expected = new UnsortedFileCommandContainer(); |
| 197 | + FileCommandsInCommentList commentList = new FileCommandsInCommentList(); |
| 198 | + |
| 199 | + commentList.add(new PlaybackFileCommand("test")); |
| 200 | + expected.add(commentList); |
| 201 | + |
| 202 | + assertIterableEquals(expected, actual); |
| 203 | + } |
| 204 | + |
| 205 | + @Test |
| 206 | + void testMultiInlineSerialisation() { |
| 207 | + // Actual |
| 208 | + SortedFileCommandContainer container = new SortedFileCommandContainer(); |
| 209 | + container.add("multi1", new PlaybackFileCommand("multi1")); |
| 210 | + container.add("multi1", null); |
| 211 | + |
| 212 | + container.add("multi2", null); |
| 213 | + container.add("multi2", new PlaybackFileCommand("multi2")); |
| 214 | + |
| 215 | + multi.getInlineStorage().add(container); |
| 216 | + |
| 217 | + UnsortedFileCommandContainer actual = TASmodAPIRegistry.PLAYBACK_FILE_COMMAND.handleOnSerialiseInline(0, null); |
| 218 | + |
| 219 | + // Expected |
| 220 | + UnsortedFileCommandContainer expected = new UnsortedFileCommandContainer(); |
| 221 | + FileCommandsInCommentList commentList1 = new FileCommandsInCommentList(); |
| 222 | + FileCommandsInCommentList commentList2 = new FileCommandsInCommentList(); |
| 223 | + |
| 224 | + commentList1.add(new PlaybackFileCommand("multi1")); |
| 225 | + commentList1.add(null); |
| 226 | + commentList2.add(null); |
| 227 | + commentList2.add(new PlaybackFileCommand("multi2")); |
| 228 | + expected.add(commentList1); |
| 229 | + expected.add(commentList2); |
| 230 | + |
| 231 | + assertIterableEquals(expected, actual); |
| 232 | + } |
163 | 233 | }
|
0 commit comments