Beispiel #1
0
        public async Task Save_CorrectFileContent()
        {
            var networkInfo = new NetworkInfo();

            networkInfo.ChCenterFrequency = 1;
            networkInfo.Channel           = 2;
            networkInfo.LinkQuality       = 3;
            networkInfo.Mac  = "4";
            networkInfo.Rssi = 5;
            networkInfo.Ssid = "6";

            var scanPoint = new ScanPoint();

            scanPoint.Position = new Point(7, 8);
            scanPoint.BssInfo.Add(networkInfo);

            var project = new Project();

            project.Bitmap = new byte[] { 9, 10, 11 };
            project.ScanPoints.Add(scanPoint);

            var tempFileName = Path.GetTempFileName();

            var jsonFileStorage = new JsonFileStorage <Project>(tempFileName);
            await jsonFileStorage.Save(project);

            var actual = await File.ReadAllTextAsync(tempFileName);

            var expected = await File.ReadAllTextAsync("Data\\test.json");

            Assert.Equal(expected, actual);
        }
Beispiel #2
0
        public async Task SaveLoad_CorrectProjectContent()
        {
            var random = new Random();

            var networkInfo = new NetworkInfo();

            networkInfo.ChCenterFrequency = (uint)random.Next();
            networkInfo.Channel           = (uint)random.Next();
            networkInfo.LinkQuality       = (uint)random.Next();
            networkInfo.Mac  = Guid.NewGuid().ToString();
            networkInfo.Rssi = random.Next();
            networkInfo.Ssid = Guid.NewGuid().ToString();

            var scanPoint = new ScanPoint();

            scanPoint.Position = new Point(random.Next(), random.Next());
            scanPoint.BssInfo.Add(networkInfo);

            var expected = new Project();

            expected.Bitmap = new byte[100];
            random.NextBytes(expected.Bitmap);
            expected.ScanPoints.Add(scanPoint);

            var tempFileName = Path.GetTempFileName();

            var jsonFileStorage = new JsonFileStorage <Project>(tempFileName);
            await jsonFileStorage.Save(expected);

            var actual = await jsonFileStorage.Load();

            Assert.Equal(expected, actual);
        }
Beispiel #3
0
        public async void OnSaveProject(object param)
        {
            var openFileDialog = new SaveFileDialog();

            openFileDialog.Title  = "Select project file";
            openFileDialog.Filter = "HeatMap Project|*.heatproject" +
                                    "|All Files|*.*";
            if (openFileDialog.ShowDialog() == true)
            {
                IStorage <Project> str = new JsonFileStorage <Project>(openFileDialog.FileName);
                await str.Save(ScanVm.Project);

                ScanVm.IsModified = false;
            }
        }