Changeset 57 in tmcsimulator-scriptbuilder for trunk/test/scriptbuilder/structures
- Timestamp:
- 08/14/2017 02:46:52 PM (9 years ago)
- Location:
- trunk/test/scriptbuilder/structures
- Files:
-
- 1 added
- 1 edited
-
TimeSliceTest.java (modified) (11 diffs)
-
single_timeslice_output_expected.xml (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/scriptbuilder/structures/TimeSliceTest.java
r56 r57 1 1 package scriptbuilder.structures; 2 2 3 import java.io.File; 4 import java.io.IOException; 5 import java.nio.file.Files; 6 import java.util.logging.Level; 7 import java.util.logging.Logger; 3 8 import junit.framework.TestCase; 9 import scriptbuilder.structures.events.AudioEvent; 10 import scriptbuilder.structures.events.CHPRadioEvent; 4 11 import scriptbuilder.structures.events.I_ScriptEvent; 5 12 … … 8 15 * @author Bryan McGuffin 9 16 */ 10 public class TimeSliceTest extends TestCase { 11 12 public TimeSliceTest(String testName) { 17 public class TimeSliceTest extends TestCase 18 { 19 20 public TimeSliceTest(String testName) 21 { 13 22 super(testName); 14 23 } … … 20 29 { 21 30 System.out.println("addEvent"); 22 I_ScriptEvent event = null; 23 TimeSlice instance = null; 31 I_ScriptEvent event = new CHPRadioEvent(); 32 TimeSlice instance = new TimeSlice(0, null); 33 34 assertEquals(0, instance.events.size()); 24 35 instance.addEvent(event); 25 // TODO review the generated test code and remove the default call to fail. 26 fail("The test case is a prototype."); 36 assertEquals(1, instance.events.size()); 27 37 } 28 38 … … 33 43 { 34 44 System.out.println("getX"); 35 TimeSlice instance = n ull;45 TimeSlice instance = new TimeSlice(0, null); 36 46 int expResult = 0; 37 47 int result = instance.getX(); 38 48 assertEquals(expResult, result); 39 // TODO review the generated test code and remove the default call to fail.40 fail("The test case is a prototype.");41 49 } 42 50 … … 47 55 { 48 56 System.out.println("getTime"); 49 TimeSlice instance = n ull;50 int expResult = 0;57 TimeSlice instance = new TimeSlice(100, null); 58 int expResult = 100; 51 59 int result = instance.getTime(); 52 60 assertEquals(expResult, result); 53 // TODO review the generated test code and remove the default call to fail.54 fail("The test case is a prototype.");55 61 } 56 62 … … 61 67 { 62 68 System.out.println("shift"); 63 int amnt = 0; 64 TimeSlice instance = null; 69 int amnt = 25; 70 TimeSlice instance = new TimeSlice(100, null); 71 assertEquals(100, instance.getTime()); 65 72 instance.shift(amnt); 66 // TODO review the generated test code and remove the default call to fail. 67 fail("The test case is a prototype."); 73 assertEquals(125, instance.getTime()); 68 74 } 69 75 … … 74 80 { 75 81 System.out.println("getEffectiveDuration"); 76 TimeSlice instance = null; 77 int expResult = 0; 78 int result = instance.getEffectiveDuration(); 79 assertEquals(expResult, result); 80 // TODO review the generated test code and remove the default call to fail. 81 fail("The test case is a prototype."); 82 TimeSlice instance = new TimeSlice(0, null); 83 assertEquals(0, instance.getEffectiveDuration()); 84 85 ScriptEvent ev1 = new AudioEvent(); 86 assertEquals(1, ev1.getLength()); 87 instance.addEvent(ev1); 88 assertEquals(1, instance.getEffectiveDuration()); 89 90 ScriptEvent ev2 = new AudioEvent(); 91 ev2.length = 25; 92 assertEquals(25, ev2.getLength()); 93 instance.addEvent(ev2); 94 assertEquals(25, instance.getEffectiveDuration()); 82 95 } 83 96 … … 89 102 System.out.println("getToolTipText"); 90 103 int y = 0; 91 TimeSlice instance = n ull;104 TimeSlice instance = new TimeSlice(0, null); 92 105 String expResult = ""; 93 String result = instance.getToolTipText(y); 94 assertEquals(expResult, result); 95 // TODO review the generated test code and remove the default call to fail. 96 fail("The test case is a prototype."); 106 String result = instance.getToolTipText(0); 107 assertEquals(null, result); 108 109 result = instance.getToolTipText(56); 110 assertEquals(null, result); 111 112 result = instance.getToolTipText(50); 113 assertEquals(null, result); 114 115 result = instance.getToolTipText(80); 116 assertEquals(null, result); 117 118 AudioEvent ev = new AudioEvent(); 119 instance.addEvent(ev); 120 expResult = "<html>" + ev.toString() + "<br/></html>"; 121 122 result = instance.getToolTipText(56); 123 assertEquals(ev.toString(), result); 124 125 result = instance.getToolTipText(70); 126 assertEquals(ev.toString(), result); 127 128 result = instance.getToolTipText(85); 129 assertEquals(null, result); 130 131 result = instance.getToolTipText(50); 132 assertEquals(expResult, result); 133 134 result = instance.getToolTipText(0); 135 assertEquals(null, result); 97 136 } 98 137 … … 103 142 { 104 143 System.out.println("toString"); 105 TimeSlice instance = n ull;144 TimeSlice instance = new TimeSlice(0, null); 106 145 String expResult = ""; 107 146 String result = instance.toString(); 108 147 assertEquals(expResult, result); 109 // TODO review the generated test code and remove the default call to fail. 110 fail("The test case is a prototype."); 148 149 AudioEvent ev1 = new AudioEvent(); 150 CHPRadioEvent ev2 = new CHPRadioEvent(); 151 152 instance.addEvent(ev1); 153 instance.addEvent(ev2); 154 155 expResult = ev1.toString() + "\n" + ev2.toString() + "\n"; 156 result = instance.toString(); 157 assertEquals(expResult, result); 111 158 } 112 159 … … 117 164 { 118 165 System.out.println("compareTo"); 119 Object o = null; 120 TimeSlice instance = null; 121 int expResult = 0; 166 Object o = new SimulationScript(); 167 168 TimeSlice other = new TimeSlice(10, null); 169 170 TimeSlice instance = new TimeSlice(0, null); 122 171 int result = instance.compareTo(o); 123 assertEquals(expResult, result); 124 // TODO review the generated test code and remove the default call to fail. 125 fail("The test case is a prototype."); 172 assertEquals(0, result); 173 174 result = instance.compareTo(other); 175 assertEquals(-1, result); 176 177 result = other.compareTo(instance); 178 assertEquals(1, result); 179 180 result = instance.compareTo(instance); 181 assertEquals(0, result); 182 126 183 } 127 184 … … 131 188 public void testToXML() 132 189 { 133 System.out.println("toXML"); 134 TimeSlice instance = null; 135 String expResult = ""; 136 String result = instance.toXML(); 137 assertEquals(expResult, result); 138 // TODO review the generated test code and remove the default call to fail. 139 fail("The test case is a prototype."); 190 try 191 { 192 System.out.println("toXML"); 193 SimulationScript script = new SimulationScript(); 194 script.loadScriptFromFile(new File("test/scriptbuilder/structures/single_timeslice_output_expected.xml")); 195 TimeSlice instance = script.incidents.get(0).slices.get(0); 196 197 byte[] data = Files.readAllBytes( 198 new File("test/scriptbuilder/structures/single_timeslice_output_expected.xml").toPath()); 199 200 String expResult = new String(data); 201 202 String result = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" 203 + "<!DOCTYPE TMC_SCRIPT SYSTEM \"script.dtd\">\n" 204 + XMLWriter.openTag(ELEMENT.TMC_SCRIPT.tag + " title=\"" + script.title + "\"") 205 + instance.toXML() 206 + XMLWriter.closeTag(ELEMENT.TMC_SCRIPT.tag); 207 208 assertEquals(expResult, result); 209 210 } 211 catch (IOException ex) 212 { 213 Logger.getLogger(TimeSliceTest.class.getName()).log(Level.SEVERE, null, ex); 214 } 140 215 } 141 216
Note: See TracChangeset
for help on using the changeset viewer.
