Пример #1
0
        /// <summary>
        /// test generate default message of VB and FB from csv and xml
        /// </summary>
        public void test_DefaultGenerateMessage()
        {
            BeaconMessage bm = new BeaconMessage();

            Debug.Assert("" == bm.GenerateMessage(null, 1));

            //Arrange
            string csv   = ".//input//validbeacons.csv";
            string xml   = ".//input//validbeacons.xml";
            BFGen  bfgen = new BFGen(csv, xml, "", false, false);

            Debug.Assert(bfgen.Init() == true);
            SyDB sydb = SyDB.GetInstance();

            int[] lineids = { 0, 1, 0x3ff };
            int   i       = 0;

            foreach (IBeaconInfo b in sydb.GetBeacons())
            {
                //Act
                BeaconMessage bm1    = new BeaconMessage();
                int           lineid = lineids[i % (lineids.Count())];
                checkbeaconmessage(b, bm1.GenerateMessage(b, lineid), lineid);
                ++i;
            }
            Debug.Assert(i == 12);
        }
Пример #2
0
        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;
            }
        }
Пример #3
0
        void RunBFGenInit(object obj)
        {
            BFGen bfgen = new BFGen("", beaconxmlfullname, "", false, false);

            bfgen.Init();
            if (obj != null)
            {
                int BMB_SDDB_distance_cm = (int)(obj);

                SyDB sydb             = SyDB.GetInstance();
                List <IBeaconInfo> bs = sydb.GetBeacons();

                Debug.Assert(bs[0].BMB_Distance_cm == BMB_SDDB_distance_cm);
            }
        }
Пример #4
0
        //check read csv file, only right range beacon will read in
        //check read xml file
        //check repeat beacon id or repeat beacon name will be ignore
        void test_BFGenIni()
        {
            //Arrange
            Func <int, bool> checkbeaconnumber = (num) =>
            {
                SyDB sydb             = SyDB.GetInstance();
                List <IBeaconInfo> bs = sydb.GetBeacons();
                Debug.Assert(bs.Count == num);//only read the valid beacons
                return(true);
            };

            Func <int, int[], bool> checkbeaconkps = (num, kps) =>
            {
                SyDB sydb             = SyDB.GetInstance();
                List <IBeaconInfo> bs = sydb.GetBeacons();
                Debug.Assert(bs.Count == num);//only read the valid beacons

                for (int i = 0; i < kps.Length; ++i)
                {
                    Debug.Assert(bs[i].kp.Value == kps[i]);
                }
                return(true);
            };

            string csv = ".//input//beacons.csv";
            string xml = ".//input//beacons.xml";
            //Arrange of wrong file type
            BFGen bfgen = new BFGen(xml, csv, "", false, false);

            //Act   Assert
            Debug.Assert(bfgen.Init() == false);

            //no file
            bfgen = new BFGen("", "", "", false, false);
            Debug.Assert(bfgen.Init() == false);

            //csv: input data valid range
            bfgen = new BFGen(csv, "", "", false, false);
            Debug.Assert(bfgen.Init() == true);
            int[] kpscsv = { 0, 10000000, 9999900, 9999910, 9999992, 9999992, 0, 10000000, 9999900, 9999910, 9999992, 9999992 }; //valid beacon kps from csv
            checkbeaconkps(21, kpscsv);

            //csv and xml beacon repeated
            bfgen = new BFGen(csv, xml, "", false, false);
            Debug.Assert(bfgen.Init() == true);
            //delete the beacon of same name and same ID
            checkbeaconnumber(24);
        }
Пример #5
0
        public static bool checkbeaconfiles(string path, bool hasbin)
        {
            bool check = false;

            if (Directory.Exists(path) &&
                Directory.Exists(Path.Combine(path, "Beacon")))
            {
                SyDB sydb                   = SyDB.GetInstance();
                List <IBeaconInfo> bs       = sydb.GetBeacons();
                List <string>      postfixs = new List <string>();
                postfixs.Add(".xml");
                if (hasbin)
                {
                    postfixs.Add(".tgm");
                    postfixs.Add(".udf");
                }
                foreach (IBeaconInfo b in bs)
                {
                    string subpath = Path.Combine(path, "Beacon");
                    foreach (string fix in postfixs)
                    {
                        if (!File.Exists(Path.Combine(subpath, $"{b.Name}{fix}")))
                        {
                            return(false);
                        }
                        else
                        {
                            check = true;
                        }
                    }
                }
            }
            else
            {
                return(false);
            }
            return(check);
        }