source: tmcsimulator-scriptbuilder/trunk/test/scriptbuilder/structures/SimulationScriptTest.java @ 56

Revision 56, 4.3 KB checked in by bmcguffin, 9 years ago (diff)

Added test files and began filling them out. Added an integration test for XML loading and saving. Added several reference files to test against.

Line 
1package scriptbuilder.structures;
2
3import java.io.File;
4import java.io.IOException;
5import java.nio.file.Files;
6import java.util.ArrayList;
7import java.util.logging.Level;
8import java.util.logging.Logger;
9import junit.framework.TestCase;
10
11/**
12 *
13 * @author Bryan McGuffin
14 */
15public class SimulationScriptTest extends TestCase
16{
17
18    public SimulationScriptTest(String testName)
19    {
20        super(testName);
21    }
22
23    /**
24     * Test of update method, of class SimulationScript.
25     */
26    public void testUpdate()
27    {
28        System.out.println("update");
29        SimulationScript instance = new SimulationScript();
30        instance.update();
31        // TODO review the generated test code and remove the default call to fail.
32        fail("The test case is a prototype.");
33    }
34
35    /**
36     * Test of broadcastEvent method, of class SimulationScript.
37     */
38    public void testBroadcastEvent_ScriptIncidentSliceChangedEvent()
39    {
40        System.out.println("broadcastEvent");
41        ScriptIncident.SliceChangedEvent e = null;
42        SimulationScript instance = new SimulationScript();
43        instance.broadcastEvent(e);
44        // TODO review the generated test code and remove the default call to fail.
45        fail("The test case is a prototype.");
46    }
47
48    /**
49     * Test of broadcastEvent method, of class SimulationScript.
50     */
51    public void testBroadcastEvent_ScriptIncidentIncidentFocusedEvent()
52    {
53        System.out.println("broadcastEvent");
54        ScriptIncident.IncidentFocusedEvent e = null;
55        SimulationScript instance = new SimulationScript();
56        instance.broadcastEvent(e);
57        // TODO review the generated test code and remove the default call to fail.
58        fail("The test case is a prototype.");
59    }
60
61    /**
62     * Test of loadScriptFromFile method, of class SimulationScript.
63     */
64    public void testLoadScriptFromFile()
65    {
66        System.out.println("loadScriptFromFile");
67        File f = null;
68        SimulationScript instance = new SimulationScript();
69        instance.loadScriptFromFile(f);
70        // TODO review the generated test code and remove the default call to fail.
71        fail("The test case is a prototype.");
72    }
73
74    /**
75     * Test of saveScriptToFile method, of class SimulationScript.
76     */
77    public void testSaveScriptToFile()
78    {
79        System.out.println("saveScriptToFile");
80        File f = null;
81        SimulationScript instance = new SimulationScript();
82        instance.saveScriptToFile(f);
83        // TODO review the generated test code and remove the default call to fail.
84        fail("The test case is a prototype.");
85    }
86
87    /**
88     * Test of toXML method, of class SimulationScript.
89     */
90    public void testToXML()
91    {
92        try
93        {
94            System.out.println("toXML");
95            File inFile = new File("test/scriptbuilder/structures/test_input_file.xml");
96            assertTrue(inFile.exists());
97            SimulationScript instance = new SimulationScript();
98
99            instance.loadScriptFromFile(inFile);
100
101            String expResult = "";
102
103            byte[] data = Files.readAllBytes(inFile.toPath());
104
105            expResult = new String(data);
106            String result = instance.toXML();
107            assertEquals(expResult, result);
108        }
109        catch (IOException ex)
110        {
111            Logger.getLogger(SimulationScriptTest.class.getName()).log(Level.SEVERE, null, ex);
112        }
113    }
114
115    /**
116     * Test of allSlices method, of class SimulationScript.
117     */
118    public void testAllSlices()
119    {
120        System.out.println("allSlices");
121        SimulationScript instance = new SimulationScript();
122        ArrayList<TimeSlice> expResult = null;
123        ArrayList<TimeSlice> result = instance.allSlices();
124        assertEquals(expResult, result);
125        // TODO review the generated test code and remove the default call to fail.
126        fail("The test case is a prototype.");
127    }
128
129    /**
130     * Test of absoluteLength method, of class SimulationScript.
131     */
132    public void testAbsoluteLength()
133    {
134        System.out.println("absoluteLength");
135        SimulationScript instance = new SimulationScript();
136        int expResult = 0;
137        int result = instance.absoluteLength();
138        assertEquals(expResult, result);
139        // TODO review the generated test code and remove the default call to fail.
140        fail("The test case is a prototype.");
141    }
142
143}
Note: See TracBrowser for help on using the repository browser.