package referencelibrary;

import org.junit.Before;
import org.junit.Test;
import referencelibrary.data.StubDao;
import referencelibrary.reference.BookReference;
import referencelibrary.reference.Reference;

import java.util.List;

import static org.junit.Assert.*;
import referencelibrary.util.FileUtil;

/**
 * Created by petri on 18.4.2016.
 */
public class AppTest {
    private App app;

    @Before
    public void setUp() {
        app = new App(new StubDao());
    }

    @Test
    public void newReference() {
        app.newReference(new BookReference("REF1"));
        List<Reference> reflist = app.listReferences();
        assertEquals(2, reflist.size());
        assertEquals("REF1", reflist.get(1).getReferenceName());
    }

    @Test
    public void listReferences() {
        List<Reference> reflist = app.listReferences();
        assertEquals("REF", reflist.get(0).getReferenceName());
    }

    @Test
    public void generateBixTexFile() {
        String filename = "test_bibtex.bib";
        app.generateBixTexFile(filename);
        String result = FileUtil.Read(filename);
        assertEquals("@Book{REF,\n}\n\n", result);
    }

}
@@ -20,16 +20,37 @@
 brary;%0A%0A
+import java.io.File;%0A
 import o
@@ -66,16 +66,16 @@
 Before;%0A
-
 import o
@@ -244,16 +244,40 @@
 il.List;
+%0Aimport org.junit.After;
 %0A%0Aimport
@@ -409,16 +409,71 @@
 pTest %7B%0A
+    private final String filename = %22test_bibtex.bib%22;%0A
     priv
@@ -558,24 +558,213 @@
 StubDao());%0A
+        File testFile = new File(filename);%0A        testFile.delete();%0A    %7D%0A%0A    @After%0A    public void tearDown() %7B%0A        File testFile = new File(filename);%0A        testFile.delete();%0A
     %7D%0A%0A    @
@@ -1197,32 +1197,32 @@
    %7D%0A%0A    @Test%0A
+
     public void 
@@ -1248,53 +1248,8 @@
 ) %7B%0A
-        String filename = %22test_bibtex.bib%22;%0A
     

Make BookReference test cleanup test file