Skip to content

Commit c9b5e87

Browse files
committed
[FileCommands] Add serialisation tests, update JUnit
1 parent ff5453d commit c9b5e87

File tree

2 files changed

+71
-1
lines changed

2 files changed

+71
-1
lines changed

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ dependencies {
5555
minecraft "com.mojang:minecraft:${project.minecraft_version}"
5656
mappings "net.legacyfabric:yarn:${project.minecraft_version}+build.mcp"
5757
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
58-
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.0'
58+
testImplementation 'org.junit.jupiter:junit-jupiter:5.12.2'
5959
}
6060

6161
// task for downloading KillTheRng

src/test/java/tasmod/playback/filecommands/PlaybackFileCommandTest.java

+70
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package tasmod.playback.filecommands;
22

33
import static org.junit.jupiter.api.Assertions.assertEquals;
4+
import static org.junit.jupiter.api.Assertions.assertIterableEquals;
45

56
import org.junit.jupiter.api.AfterEach;
67
import org.junit.jupiter.api.BeforeEach;
@@ -160,4 +161,73 @@ void testMultiInlineDeserialisation() {
160161

161162
assertEquals(expected, actual);
162163
}
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+
}
163233
}

0 commit comments

Comments
 (0)