You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.2 KiB

import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import java.io.File;
import static org.junit.jupiter.api.Assertions.*;
class StorageTest {
static Storage storage;
static String testFilePath = "/tmp/test.txt";
@BeforeAll
static void init() {
storage = new Storage();
if (System.getProperty("os.name").toLowerCase().contains("win")) {
testFilePath = "C:\\test.txt";
}
}
@AfterAll
static void clear() {
File myObj = new File(testFilePath);
myObj.delete();
}
@Test
void constructor() {
assertInstanceOf(Storage.class, storage);
}
@Test
void export() {
}
@Test
void load() {
}
@Test
void writeFile() {
String content = "test";
assertTrue(storage.writeFile(testFilePath, content));
File f = new File(testFilePath);
assertTrue(f.isFile());
}
@Test
void readFile() {
String content = "test";
File f = new File(testFilePath);
if (!f.isFile()) {
assertTrue(storage.writeFile(testFilePath, content));
}
assertEquals(content, storage.readFile(testFilePath));
}
}