public void WTTCautionSpeedSet_Constructor_XElement() { string TestXMLPath = $"{System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)}\\Resources\\TestThreeBridges_4.8.xml"; XElement XMLTestCautionSpeedSet = XDocument.Load(TestXMLPath).Element("SimSigTimetable").Element("CautionSpeedSets").Element("CautionSpeedSet"); GroundFrame.Core.Timetables.WTTCautionSpeedSet TestCautionSpeedSet = new Timetables.WTTCautionSpeedSet(XMLTestCautionSpeedSet); Assert.Equal(XMLTestCautionSpeedSet.Attribute("ID").Value, TestCautionSpeedSet.SimSigID); Assert.Equal(XMLTestCautionSpeedSet.Element("Name").Value, TestCautionSpeedSet.Name); Assert.Equal(XMLTestCautionSpeedSet.Elements("CautionSpeeds").Elements("CautionSpeed").Count(), TestCautionSpeedSet.CautionSpeeds.Count); Assert.Equal((WTTSignalAspect)Convert.ToInt32(XMLTestCautionSpeedSet.Elements("CautionSpeeds").Elements("CautionSpeed").ElementAt(0).Element("AspectPassed").Value), TestCautionSpeedSet.CautionSpeeds[0].AspectPassed); }
public void WTTCautionSpeedSet_Method_RemoveAt() { string TestXMLPath = $"{System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)}\\Resources\\TestThreeBridges_4.8.xml"; XElement XMLTestCautionSpeedSet = XDocument.Load(TestXMLPath).Element("SimSigTimetable").Element("CautionSpeedSets").Element("CautionSpeedSet"); GroundFrame.Core.Timetables.WTTCautionSpeedSet TestCautionSpeedSet = new Timetables.WTTCautionSpeedSet(XMLTestCautionSpeedSet); //Test Before Assert.Equal(XMLTestCautionSpeedSet.Elements("CautionSpeeds").Elements("CautionSpeed").Count(), TestCautionSpeedSet.CautionSpeeds.Count); //Remove 1 TestCautionSpeedSet.RemoveAt(0); //Test After - Should be 1 Less Assert.Equal(XMLTestCautionSpeedSet.Elements("CautionSpeeds").Elements("CautionSpeed").Count() - 1, TestCautionSpeedSet.CautionSpeeds.Count); }