Exemple #1
0
        public void ReadXmlTest()
        {
            Sensor           s  = new Sensor(100, 0, 0, null);
            SensorCollection sc = new SensorCollection();

            sc.List.Add(s);
            s = new Sensor(101, 0, 0, null);
            sc.List.Add(s);
            s = new Sensor(102, 0, 0, null);
            sc.List.Add(s);

            sc.WriteToFile(Names.SensorCollectionXml);

            SensorCollection collection = SensorCollection.ReadFromFile(FileManager.GetFullPath(Names.SensorCollectionXml));

            if (collection.List == null || collection.List.Count == 0)
            {
                Assert.Fail();
            }
        }
Exemple #2
0
        public static string CreateEmptySensorFile(string path)
        {
            var fullPath = GetFullPath(path);

            if (Exists(fullPath))
            {
                int index = fullPath.LastIndexOf(".xml");
                fullPath = fullPath.Substring(0, index) + "-copy.xml";
                return(CreateEmptySensorFile(fullPath));
            }
            else
            {
                var sensor           = new Sensor(0, new Point(0, 0), null, 0, new Battery(0, 0));
                var sensorCollection = new SensorCollection();
                sensorCollection.List.Add(sensor);

                sensorCollection.WriteToFile(fullPath);
                return(fullPath);
            }
        }