public void test_GenrateDeviceByIBBM() { //Arrange sydb.clear(); List <LEU> leulist = new List <LEU>(); List <BEACON> blist = new List <BEACON>(); BMVFGen bvf = new BMVFGen(false, ref blist, ref leulist); // initial //Act Assert Debug.Assert(false == bvf.GenrateDeviceByIBBM()); //Arrange BFGen bf = new BFGen(".//input//validbeacons.csv", "", "", false, false); bf.Init(); List <string> validleunames = new List <string>() { "E1D", "E2D", "E3D", "E1C", "E3D2", "E2D2", "E2D3", "E2C1", "E2C7" }; GENERIC_SYSTEM_PARAMETERS.IMPLEMENTATION_BEACON_BLOCK_MODE ibbms = FileLoader.Load <GENERIC_SYSTEM_PARAMETERS.IMPLEMENTATION_BEACON_BLOCK_MODE>(".//input//IBBM.xml"); sydb.ibbmInfoList.Clear(); sydb.ibbmInfoList = ibbms.BM_Beacon; // read all IBBM beacons //Act Debug.Assert(true == bvf.GenrateDeviceByIBBM()); //Assert foreach (IBeaconInfo b in sydb.GetBeacons()) { if (b.IsVariantBeacon() == true) { Debug.Assert(blist.Exists(x => x.Name == b.Name)); } else { Debug.Assert(false == blist.Exists(x => x.Name == b.Name)); } } leulist.ForEach(Print); Debug.Assert(validleunames.Count == leulist.Count()); int leuid = 1; foreach (LEU l in leulist) { Debug.Assert(leuid == l.ID); Debug.Assert(l.Name == validleunames[leuid - 1]); ++leuid; } }
public void test_GenerateBMBSDDBDisInfoNode() { List <LEU> leulist = new List <LEU>(); List <BEACON> blist = new List <BEACON>(); BMVFGen bmvf = new BMVFGen(false, ref blist, ref leulist); XmlVisitor beaconNodenull = XmlVisitor.Create("Beacon", null); Debug.Assert(false == bmvf.GenerateBMBSDDBDisInfoNode(null, ref beaconNodenull)); Prepare.ReloadGlobalSydb(".//input//BMBDisSydb.xml"); BFGen bf = new BFGen(".//input//BMBDisBeacons.csv", ".//input//BMBDisBeacons.xml", "", false, false); MethodHelper.InvokePrivateMethod <BFGen>(bf, "Init"); bmvf.GenrateDeviceByIBBM(); //the corresponding beacons are: //VB0102 VB0106 vb0101 vb0110 vb0111 vb0203 VB0609 vb1402 VB1303 ib1303 vb2002 fb1914 vb1705 VB0614 VB0601 VB0604 string[] validdis = { "8.630", "5.910", "6.410", "5.340", "6.020", "6.060", "5.710", "5.550", "5.650", "5.650", "130.580", "44.740", "73.580", "3.230", "3.100", "6.000" }; #region test the beacons of valid bmbdis { int beaconi = 0; foreach (var curdis in validdis) { XmlVisitor beaconNode = XmlVisitor.Create("Beacon", null); haschecked = false; Debug.Assert(true == bmvf.GenerateBMBSDDBDisInfoNode(blist[beaconi], ref beaconNode)); //check BMBSDDB calculate and node generate Debug.Assert(curdis == Prepare.getXmlNodeStr(beaconNode, "BMB_SDDB_distance")); //check BeaconMessage use the right BMB_Dis BeaconMessage bm = new BeaconMessage(); bm.GenerateMessage(blist[beaconi], 1, null); Debug.Assert(bm.BMB_Distance_Unitcm() == blist[beaconi].BMB_Distance_cm); ++beaconi; } } #endregion #region test the beacons of invalid bmbdis {//IB0302 FB1916 int errBeaconi = validdis.Length; for (; errBeaconi < blist.Count; errBeaconi++) { Debug.Assert(false == bmvf.GenerateBMBSDDBDisInfoNode(blist[errBeaconi], ref beaconNodenull)); } } #endregion }