示例#1
0
        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));
            }
        }
示例#2
0
        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));
                }
        }
示例#3
0
        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));
            }
        }
示例#4
0
        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);
        }
示例#5
0
        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);
            }
        }
示例#6
0
        public void ParseSoftConflictsTtNullTest()
        {
            var fop = new FetOutputProcessorExposer("", "");

            Assert.DoesNotThrow(() => { fop.AddMetadata(null); });
        }