void test_splitRoute() { Prepare.ReloadGlobalSydb(".//input//Routes_fromHHHT2.xml"); RouteSegConfig SyDBRouteCfg = new RouteSegConfig(sydb); Debug.Assert(false == SyDBRouteCfg.splitRoute(null)); int[] rids = { 183,161,66,76,231 }; //these route has Spacing_Signal_ID_List, 231 has no Spacing_Signal_ID_List also can be test by this foreach (int id in rids) { //test blockinfo of route has Spacing_Signal_ID_List clearlist(SyDBRouteCfg); var sydbroute = sydb.routeInfoList.Find(x => x.ID == id); Debug.Assert(true == SyDBRouteCfg.splitRoute(sydbroute)); Debug.Assert(SyDBRouteCfg.m_RouteSpacing_routeLst[0].m_OrgSig.ID == sydbroute.Origin_Signal_ID); //get RouteSpacing_route start with same sig as 183 Debug.Assert(SyDBRouteCfg.m_Spacing_routeLst.Count == sydbroute.Spacing_Signal_ID_List.Signal_ID.Count); //get some Spacing_route List <StringData> blocks = new List <StringData>(); SyDBRouteCfg.m_Spacing_routeLst.AddRange(SyDBRouteCfg.m_RouteSpacing_routeLst); foreach (var r in SyDBRouteCfg.m_Spacing_routeLst) { foreach (var b in r.m_BlkLst) { blocks.Add(b.ID); } } Debug.Assert(sydbroute.Block_ID_List.Block_ID.All(blocks.Contains));//add all split route blocks == orinal route blocks } { //test pointlist of route has no Spacing_Signal_ID_List clearlist(SyDBRouteCfg); var sydbroute = sydb.routeInfoList.Find(x => x.ID == 231); //this route has no Spacing_Signal_ID_List Debug.Assert(true == SyDBRouteCfg.splitRoute(sydbroute)); Debug.Assert(SyDBRouteCfg.m_RouteSpacing_routeLst[0].m_OrgSig.ID == sydbroute.Origin_Signal_ID); //get RouteSpacing_route same as 231 GENERIC_SYSTEM_PARAMETERS.SIGNALS.SIGNAL dstsig = (GENERIC_SYSTEM_PARAMETERS.SIGNALS.SIGNAL)MethodHelper.InvokePrivateMember(SyDBRouteCfg.m_RouteSpacing_routeLst[0],"DstSig"); Debug.Assert(dstsig.ID == sydbroute.Destination_Signal_ID); Debug.Assert(SyDBRouteCfg.m_Spacing_routeLst.Count == 0);//get no Spacing_route } }
void test_RouteSegment() { Prepare.ReloadGlobalSydb(".//input//Routes_fromHHHT2.xml"); { var sydbroute = sydb.routeInfoList.Find(x => x.ID == 224);//this route has no points RouteSegment newr = new RouteSegment(sydbroute); Debug.Assert(newr.m_PtLst.Count == 0); } { //check length for oginal route var sydbroute = sydb.routeInfoList.Find(x => x.ID == 231); //this route has points RouteSegment newr = new RouteSegment(sydbroute); List <string> pnames = new List <string>() { "P01D-N","P07D-R","P09D-R" }; //the pts in route 231 int i = 0; foreach (var p in newr.m_PtLst) //check for route get points info { Debug.Assert(pnames[i] == p.getNamePosStr()); ++i; } Debug.Assert((626856 - 615248 + 41374 - 26856) == newr.GetLength()); } { //check length for the splitted routes var sydbroute = sydb.routeInfoList.Find(x => x.ID == 183); //this route has Spacing_Signal_ID_List RouteSegConfig SyDBRouteCfg = new RouteSegConfig(sydb); clearlist(SyDBRouteCfg); SyDBRouteCfg.splitRoute(sydbroute); SyDBRouteCfg.m_RouteSpacing_routeLst.AddRange(SyDBRouteCfg.m_Spacing_routeLst); int[] lengths = { 1170639 - 906 - (1058617 - 747),1058617 - 747 - (1041880 - 747),(1041880 - 747) - (963697 + 176) };//length for the splitted route int i = 0; foreach (var r in SyDBRouteCfg.m_RouteSpacing_routeLst) { Debug.Assert(lengths [i] == r.GetLength()); ++i; } } }