public void XmlToTimetableTest() { var fop = new FetOutputProcessorExposer("", ""); // Create output file stream var testDataPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "testdata/fet/United-Kingdom/Hopwood/output.xml"); using (var outputFileStream = File.OpenRead(testDataPath)) { // Deserialize XML Assert.DoesNotThrow(() => fop.XmlToTimetable(outputFileStream, null)); } }
public void ParseSoftConflictsEndTest() { var testline = "\r\nEnd of file.\r\nTest soft conflict warning\r\n"; var expected = new List <string>(); var fop = new FetOutputProcessorExposer("", ""); using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(testline))) using (var reader = new StreamReader(stream)) { Assert.AreEqual(expected, fop.ParseSoftConflicts(reader)); } }
public void CorruptXmlToTimetableTest() { const string contents = "Hey this is not XML!"; var fop = new FetOutputProcessorExposer("", ""); var byteArray = Encoding.UTF8.GetBytes(contents); // Create output file stream using (var outputFileStream = new MemoryStream(byteArray)) { // Deserialize XML Assert.Throws <InvalidOperationException>(() => fop.XmlToTimetable(outputFileStream, null)); } }
public void ParseMetaLineTest() { var tt = new Timetable(); var fop = new FetOutputProcessorExposer("", ""); var input_1 = "Warning! Only 197 out of 479 activities placed!"; uint expected_1 = 197; var input_2 = "Total conflicts: 5640361.15"; double expected_2 = 5640361.15d; fop.ParseMetaLine(input_1, tt); Assert.AreEqual(expected_1, tt.PlacedActivities); fop.ParseMetaLine(input_2, tt); Assert.AreEqual(expected_2, tt.ConflictWeight); }
public void XmlToTimetableActivitiesTest() { var fop = new FetOutputProcessorExposer("", ""); var expected = new Activity { Id = 3 }; var activities = new Dictionary <int, Activity> { { 3, expected } }; // Create output file stream var testDataPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "testdata/fet/United-Kingdom/Hopwood/output.xml"); using (var outputFileStream = File.OpenRead(testDataPath)) { var tt = fop.XmlToTimetable(outputFileStream, activities); // Find activity in timetable output and check that it's associated resource matches Assert.AreEqual(expected, tt.Activities.Find(i => i.Id == "3").Resource); } }
public void ParseSoftConflictsTtNullTest() { var fop = new FetOutputProcessorExposer("", ""); Assert.DoesNotThrow(() => { fop.AddMetadata(null); }); }