Skip to content
Snippets Groups Projects
Commit e8ccaec0 authored by Andreas's avatar Andreas
Browse files

Made test for method writeItemRegisterToFile

parent be87853d
No related branches found
No related tags found
2 merge requests!9Added FileHandling class for ItemRegister objects, and reworked ItemRegister with new subclasses,!8Remade ItemRegister class and made FileHandling for ItemRegister-objects with tests
Pipeline #208106 passed
......@@ -132,10 +132,10 @@ public abstract class Item {
public String toString() {
String isRecuring = "";
if(recurring){
isRecuring = "Recuring";
isRecuring = "Reoccurring";
}
else if(!recurring){
isRecuring = "Not recuring";
else{
isRecuring = "Not reoccurring";
}
if(!description.isBlank()){
return date+"\n"+description+"\n"+amount+"\n"+isRecuring+"\n";
......
package no.ntnu.idatt1002.demo.data.Economics;
import org.junit.jupiter.api.*;
import java.io.FileNotFoundException;
import java.io.IOException;
import static org.junit.jupiter.api.Assertions.*;
class FileHandlingTest {
FileHandling fileHandling = new FileHandling();
ItemRegister<Income> incomeRegister = new ItemRegister<>();
@Test
@DisplayName("Try to write to file an incomeRegister with one Item")
void writeIncomeRegisterToFile() throws IOException {
Income income1 = new Income("description1", 59.9f, false, IncomeCategory.SALARY, "03.03.23");
Income income2 = new Income("description2", 62.4f, true, IncomeCategory.GIFT, "01.02.21");
Income income3 = new Income("description3", 9.81f, false, IncomeCategory.SALARY, "05.07.23");
incomeRegister.addItem(income1);
incomeRegister.addItem(income2);
incomeRegister.addItem(income3);
fileHandling.writeItemRegisterToFile(incomeRegister, "income1");
}
}
\ No newline at end of file
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