Esempio n. 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());
        }
 /// <summary>
 /// Pobiera pomiary dla podanej stacji, zapisując je do podanego Containera
 /// </summary>
 /// <param name="meteoStation"></param>
 /// <param name="dc"></param>
 public void GetMeasurementsOfStation(MeteoStation meteoStation, DataContainer dc)
 {
     var pressures = from p in GetPressures()
         where p.MeteoStationOfMeasurement.Id == meteoStation.Id
         select p;
     var temperatures = from p in GetTemperatures()
             where p.MeteoStationOfMeasurement.Id == meteoStation.Id
             select p;
     var wetneses = from p in GetWetneses()
              where p.MeteoStationOfMeasurement.Id == meteoStation.Id
              select p;
     SaveMeasurementsToContainer(temperatures.ToList(), pressures.ToList(), wetneses.ToList(), dc );
 }
Esempio n. 3
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 AddMeteoStationNameTest()
 {
     DataContainer dc = new DataContainer();
     MeteoStation ms = new MeteoStation(); //{Name = "Stacyjka", LocationOfInstalation = new Location {City = "Poznan", Province = "Kaszubskie"}};
     try
     {
         dc.AddMeteostation(ms);
         Assert.Fail("Stacja powinna byc zawsze nazwana");
     }
     catch (NoNamedStationException)
     {
         Assert.Pass();
     }
     catch(Exception e)
     {
         Assert.Fail(e.Message);
     }
 }
 public void AddMeteoStationLocationTest()
 {
     DataContainer dc = new DataContainer();
     MeteoStation ms = new MeteoStation {Name = "Stacyjka"};
     try
     {
         dc.AddMeteostation(ms);
         Assert.Fail("Stacja powinna miec lokalizacje");
     }
     catch (NonLocatedStationException)
     {
         Assert.Pass();
     }
     catch (Exception e)
     {
         Assert.Fail(e.Message);
     }
 }
Esempio n. 6
0
 public void AddMeteoStation(string nazwa, string miasto,
                         string wojewodztwo, DateTime dataInstalacji)
 {
     DataContainer dc = new DataContainer();
      dc.AddMeteostation(CreateStation(nazwa, miasto, wojewodztwo, dataInstalacji));
 }
Esempio n. 7
0
 public void AddLocation(string city, string province)
 {
     DataContainer dc = new DataContainer();
     dc.AddLocation(CreateLocation(city,province));
 }
 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");
     }
 }
 /// <summary>
 /// Pomocnicza metoda, przepisująca listy pobrane z Repository do Containera.
 /// </summary>
 /// <param name="temperatureList"></param>
 /// <param name="pressuresList"></param>
 /// <param name="wetnesesList"></param>
 /// <param name="dc"></param>
 private void SaveMeasurementsToContainer(List<Temperature> temperatureList, 
     List<Pressure> pressuresList,
     List<Wetness> wetnesesList, 
     DataContainer dc)
 {
     dc.TemperatureList = temperatureList;
     dc.PressureList = pressuresList;
     dc.WetnessList = wetnesesList;
 }