Пример #1
0
        public void SaveMeasurement(double pressureValue, double temperatureValue, double wetnessValue, string stationName, DateTime dateOfMeasurement)
        {
            DataContainer dc = new DataContainer();
            DataRepository dr = new DataRepository();
            var stations = from meteostaion in dr.GetMeteoStations() where meteostaion.Name == stationName select meteostaion;

            dc.PressureList.Add(new Pressure { Value = pressureValue, Unit = "hPA", DateOfMeasuement = dateOfMeasurement, MeteoStationOfMeasurement = stations.First() });
            dc.TemperatureList.Add(new Temperature { Value = temperatureValue, Unit = "C", DateOfMeasuement = dateOfMeasurement, MeteoStationOfMeasurement = stations.First() });
            dc.WetnessList.Add(new Wetness { Value = wetnessValue, Unit = "%", DateOfMeasuement = dateOfMeasurement, MeteoStationOfMeasurement = stations.First() });

            dc.SaveMeasurements(dr.GetCurrentDBContext());
        }
Пример #2
0
 //pochrzaniłem ;]
 public void SubmitMeasurements(string temperatureValue, string unitT, string pressureValue, string unitP, string wetnessValue, string unitW,  //Wywołanie tej funkcji wrzucasz do guzika i tyle wystarczy, chyba nic nie 
                                 DateTime timeOfMeasurement, string meteoStationName)
 {
     DataRepository dr = new DataRepository();
     var querry = from station in dr.GetMeteoStations()
         where meteoStationName == station.Name
         select station;
     List<MeteoStation> stationOfMeasurementList = querry.ToList();
     MeteoStation stationOfMeasurement = stationOfMeasurementList.First();
     DataContainer dc = new DataContainer();
     dc.PressureList.Add(SetPressure(pressureValue, unitP, timeOfMeasurement, stationOfMeasurement));
     dc.TemperatureList.Add(SetTemperature(temperatureValue, unitT, timeOfMeasurement, stationOfMeasurement));
     dc.WetnessList.Add(SetWetness(wetnessValue,unitW, timeOfMeasurement, stationOfMeasurement));
     dc.SaveMeasurements(dr.GetCurrentDBContext());
 }
 public void SaveMeasurementsDataCorrectnessTest()
 {
     DataContainer dc = new DataContainer();
     dc.TemperatureList = testTemperatureList;
     dc.PressureList = testPressureList;
     dc.WetnessList = testWetnessList;
     dc.WetnessList[3].Value = -1;
     dc.PressureList[2].Value = -3;
     try
     {
         dc.SaveMeasurements(msdbc);
         Assert.Fail("Dane są niepoprawnie walidowane");
     }
     catch (IncorrectDataException)
     {
         Assert.Pass();
     }
     catch
     {
         Assert.Fail("Nie uzyto wyjatku IncorrectDataException z folderu CustomExceptions");
     }
 }