Tournament list #11

Merged
schrom01 merged 13 commits from TournamentList into main 2022-05-01 18:45:02 +02:00
2 changed files with 40 additions and 1 deletions
Showing only changes of commit e8e64d435c - Show all commits

View File

@ -110,4 +110,9 @@ public class FileIO {
} }
} }
public void deleteTournament(File tournamentFile) throws IOException {
throw new UnsupportedOperationException("Method deleteTournament not implemented yet.");
}
} }

View File

@ -83,7 +83,10 @@ class FileIOTest {
@Test @Test
void loadTournamentNotExisting(){ void loadTournamentNotExisting(){
io = new FileIO(mainDir); io = new FileIO(mainDir);
assertThrows(FileNotFoundException.class, () -> io.loadTournament(new File("Not-existing-File"))); File file = new File("Not-existing-File");
assertFalse(file.exists());
assertThrows(FileNotFoundException.class, () -> io.loadTournament(file));
assertFalse(file.exists());
} }
@Test @Test
@ -124,4 +127,35 @@ class FileIOTest {
assertThrows(IllegalArgumentException.class, () -> io.saveTournament(null)); assertThrows(IllegalArgumentException.class, () -> io.saveTournament(null));
} }
} }
@Nested
class Delete{
@BeforeEach
void setup(){
mainDir = RESOURCES_DIR + "FileIODelete";
io = new FileIO(mainDir);
}
@Test
void deleteTournament() throws IOException {
File file = new File(mainDir + "/saves/test1.txt");
file.createNewFile();
assertTrue(file.exists());
io.deleteTournament(file);
assertFalse(file.exists());
}
@Test
void deleteTournamentNotExisting() throws IOException {
File file = new File("Not-existing-File");
assertFalse(file.exists());
assertThrows(FileNotFoundException.class, () -> io.deleteTournament(file));
assertFalse(file.exists());
}
@Test
void deleteTournamentNull(){
assertThrows(IllegalArgumentException.class, () -> io.deleteTournament(null));
}
}
} }