public void route_response_parser__parses_well_formed_xml() { string xml = @"<?xml version=""1.0"" encoding=""utf-8""?> <CTARoutes> <TimeStamp>20110818 10:53</TimeStamp> <ErrorCode>0</ErrorCode> <ErrorMessage /> <RouteInfo> <Route>Red Line</Route> <RouteColorCode>c60c30</RouteColorCode> <RouteTextColor>ffffff</RouteTextColor> <ServiceId>Red</ServiceId> <RouteURL> <![CDATA[http://www.transitchicago.com/riding_cta/systemguide/redline.aspx]]> </RouteURL> <RouteStatus>Normal Service</RouteStatus> <RouteStatusColor>404040</RouteStatusColor> </RouteInfo> <RouteInfo> <Route>Blue Line</Route> <RouteColorCode>00a1de</RouteColorCode> <RouteTextColor>ffffff</RouteTextColor> <ServiceId>Blue</ServiceId> <RouteURL> <![CDATA[http://www.transitchicago.com/riding_cta/systemguide/blueline.aspx]]> </RouteURL> <RouteStatus>Normal Service</RouteStatus> <RouteStatusColor>404040</RouteStatusColor> </RouteInfo> </CTARoutes>"; var sut = new RouteStatusResponseParser(); var response = sut.Parse(xml); Assert.IsNotNull(response); Assert.IsTrue(2 == response.RouteInfoList.Count); }
/// <summary> /// Method to query the CTA route status api. All of the parameters are optional /// </summary> /// <param name="types">Comma-delimited list of desired service types</param> /// <param name="routeIds">Single or multiple route ID(s). Comma-delimited</param> /// <param name="stationIds">Single or multiple station IDs. Comma delimited</param> /// <returns></returns> public RouteStatusResponse Execute(string types = null, string routeIds = null, string stationIds = null) { var responseXml = ExecuteXml(types, routeIds, stationIds); var parser = new RouteStatusResponseParser(); return parser.Parse(responseXml); }