Skip to content
Snippets Groups Projects
Commit 0d80322d authored by Jerusalem Laila's avatar Jerusalem Laila
Browse files

Save Manager Unit Test

parent c42b07d6
No related branches found
No related tags found
No related merge requests found
......@@ -9,7 +9,7 @@ import java.util.HashMap;
public class SaveManager {
private final static Logger log = LogManager.getLogger(SaveManager.class);
private static HashMap<String,String> scores = new HashMap<>();
public static HashMap<String,String> scores = new HashMap<>();
public static String username;
......
hi;48
dave;29
bobby;423
Laila;27
testname;31
Enter your name;33
samy;34
username;27
Bob;150
Alice;200
John;100
package org.example;
import org.example.io.SaveManager;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
import java.util.HashMap;
import static org.junit.Assert.assertEquals;
public class SaveManagerTest {
private HashMap<String, String> scores;
@Before
public void setUp() {
scores = new HashMap<>();
scores.put("John", "100");
scores.put("Alice", "200");
scores.put("Bob", "150");
}
@After
public void tearDown() {
scores.clear();
}
@Test
public void testPersist() throws IOException {
SaveManager.username = "Alice";
SaveManager.scores = scores;
SaveManager.persist();
// Überprüfen, ob die Daten erfolgreich gespeichert wurden
assertEquals("200", SaveManager.scores.get("Alice"));
// Überprüfen, ob die Daten korrekt im CSV-Dateiformat gespeichert wurden
SaveManager.load();
assertEquals("Alice", SaveManager.username);
assertEquals("200", SaveManager.scores.get("Alice"));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment