public void GetMeanTempLatestMonths_TDD()
        {
            var weatherObservation = new WeatherObservation(new FakeWeatherObservationRepository());
            var temp = weatherObservation.GetMeanTempLatestMonths(15655);

            Assert.IsNotNull(temp);
        }
        public void GetMinTempLatestDay_Counting_ReturnValue()
        {
            var weatherObservation = new WeatherObservation();
            var tempObj = weatherObservation.GetMinTempLatestDay(71190).Count();

            Assert.AreEqual(tempObj, 1);
        }
        public void GetMeanTempLatestMonths_TDD()
        {
            var weatherObservation = new WeatherObservation();
            var tempObj = weatherObservation.GetMeanTempLatestMonths(71190);

            Assert.IsNotNull(tempObj);
        }
        public void Init()
        {
            _weather = new WeatherObservation(new FakeWeatherObservationRepository());

            _windDir = _weather.GetWindDirLatestMonth(95455);

        }
        public void GetMaxTempLatestDay_TDD()
        {
            var weatherObservation = new WeatherObservation();
            var tempObj = weatherObservation.GetMaxTempLatestDay(71190);

            Assert.IsNotNull(tempObj);
        }
        public void GetMeanTempLatestDay_TDD()
        {
            var weatherObservation = new WeatherObservation(new FakeWeatherObservationRepository());

            var tempObj = weatherObservation.GetMeanTempLatestDay(17055);

            Assert.IsNotNull(tempObj);
        }
        public void GetMaxTempLatestMonths_Assert_ReturnValues()
        {
            IWeatherObservation weatherObservation = new WeatherObservation(new FakeWeatherObservationRepository());

            var data = weatherObservation.GetMaxTempLatestMonths(77777).Select(p=>p.Value).First();

            Assert.AreEqual(data, 2,6);
        }
        public void GetMaxTempLatestMonths_Counting_ReturnValues()
        {
            IWeatherObservation weatherObservation = new WeatherObservation(new FakeWeatherObservationRepository());

            var data = weatherObservation.GetMaxTempLatestMonths(77777).Count();

            Assert.AreEqual(data, 130);
        }
        public void GetMaxTempLatestMonths_TDD()
        {
            IWeatherObservation weatherObservation = new WeatherObservation(new FakeWeatherObservationRepository());

            var data = weatherObservation.GetMaxTempLatestMonths(77777);

            Assert.IsNotNull(data);
        }
        public void GetTempLatestHour_TDD()
        {
            var weatherObservation = new WeatherObservation(new FakeWeatherObservationRepository());

            var temp = weatherObservation.GetTempLatestHour(85456);

            Assert.IsNotNull(temp);
        }
        public void GetMinTempLatestDay_TDD()
        {
            IWeatherObservation weatherObservation = new WeatherObservation(new FakeWeatherObservationRepository());

            var data = weatherObservation.GetMinTempLatestDay(65458);

            Assert.IsNotNull(data);
        }
        public void GetMinTempLatestDay_Assert_ReturnValues()
        {
            IWeatherObservation weatherObservation = new WeatherObservation(new FakeWeatherObservationRepository());

            var data = weatherObservation.GetMinTempLatestDay(65458).Select(p => p.Value).First();

            Assert.AreEqual(data, 7,2);
        }
        public void GetWindDirLatestMonth_TDD()
        {
            var weather = new WeatherObservation(new FakeWeatherObservationRepository());

            var windDir = weather.GetWindDirLatestMonth(75454);

            Assert.IsNotNull(windDir);
        }
        public void GetTempLatestMonths_TDD()
        {
            var weatherObservation = new WeatherObservation(new FakeWeatherObservationRepository());

            var tempObj = weatherObservation.GetTempLatestMonths(45654);

            Assert.IsNotNull(tempObj);
        }
        public void GetMinTempLatestDay_Counting_ReturnValues()
        {
            IWeatherObservation weatherObservation = new WeatherObservation(new FakeWeatherObservationRepository());

            var data = weatherObservation.GetMinTempLatestDay(65458).Count();

            Assert.AreEqual(data, 1);
        }
        public void GetMeanTempLatestMonths_Counting_ReturnValues()
        {
            var weatherObservation = new WeatherObservation();
            var tempObj = weatherObservation.GetMeanTempLatestMonths(71190);

            var count = tempObj.Count();

            Assert.AreEqual(count, 130);
        }
        public void GetParameterList_ParameterExpectedException_FakeHttpRequestException()
        {
            //Arrange
            var injection = new FakesRepositories.FakeData.FakeHttpRequestException();

            var weatherObj = new WeatherObservation(injection);

            //Assert
            weatherObj.GetParameters();
        }
        public void GetMeanTempLatestDay_Count_Values()
        {
            var weatherObservation = new WeatherObservation(new FakeWeatherObservationRepository());

            var tempObj = weatherObservation.GetMeanTempLatestDay(5555);

            var count = tempObj.Count();

            Assert.AreEqual(count, 1);
        }
        public void GetMeanTempLatestDay_Assert_ReturnValue()
        {
            var weatherObservation = new WeatherObservation(new FakeWeatherObservationRepository());

            var tempObj = weatherObservation.GetMeanTempLatestDay(55555);

            var value = (from t in tempObj select t.Value).First();

            Assert.AreEqual(value, 8.0);
        }
        public void GetTempLatestMonth_Counting_Assert_Value()
        {
            var weatherObservation = new WeatherObservation(new FakeWeatherObservationRepository());

            var tempObj = weatherObservation.GetTempLatestMonths(544540);

            var value = (from t in tempObj select t.Value).First();

            Assert.AreEqual(value, 11.0);
        }
        public void Method_GetWeatherStations_IntergrationTest_ExpectedException()
        {
            //Arrange
            var injectionWeather = new FakeHttpRequestException();
            var injectionCache = new FakeCachedData();
            var weatherObj = new WeatherObservation(injectionWeather);

            //Assert (unexpected parameter value)
            weatherObj.GetWeatherStations(500);
        }
        public void GetTempLatestMonth_Counting_ReturnValue()
        {
            var weatherObservation = new WeatherObservation(new FakeWeatherObservationRepository());

            var tempObj = weatherObservation.GetTempLatestMonths(544540);

            var count = tempObj.Count();

            Assert.AreEqual(count, 3036);
        }
        public void CacheMemory_Methods_SetCache_And_GetCache_For_Stations()
        {
            //Arrange
            var fetchFile = new WeatherObservation();

            //Act (USE DEBUGER TO BE SURE THE SECOND GETPARAMETERS FETCHES FROM CACHE)
            var firstFetch = fetchFile.GetWeatherStations(4);
            var secondFetche = fetchFile.GetWeatherStations(4);

            //Assert
            Assert.AreSame(firstFetch, secondFetche);
        }
        public void Injected_Fake_MethodIs_GetParameterList_ListOfValues_Count()
        {
            //Arrange
            var injectionWeather = new FakeWeatherObservationRepository();
            var weatherObj = new WeatherObservation(injectionWeather);

            var listOfValues = weatherObj.GetParameters();

            //Act
            var countValues = listOfValues.Count();

            //Assert
            Assert.AreEqual(20, countValues);
        }
        public void Method_GetWeatherStations_TDD()
        {
            //Arrange
            var injectionWeather = new FakeWeatherObservationRepository();
            var injectionCache = new FakeCachedData();
            var weatherObj = new WeatherObservation(injectionWeather);

            IEnumerable<WeatherStationModel> stations = null;

            Assert.IsNull(stations);

            //Act
            stations = weatherObj.GetWeatherStations(5);

            //Assert
            Assert.IsNotNull(stations);
        }
        public void Method_GetweatherStations_Count()
        {
            //Arrange
            var injectionWeather = new FakeWeatherObservationRepository();
            var injectionCache = new FakeCachedData();
            var weatherObj = new WeatherObservation(injectionWeather);

            var listOfStations = weatherObj.GetWeatherStations(4);

            //Act
            var numberOfStations = listOfStations.Count();

            //Assert
            Assert.AreEqual(numberOfStations, 11);
            //Fails
            //Assert.AreEqual(numberOfStations, 100);
        }
        public void Injected_Fake_MethodIs_GetParameterList_ListOfValues_testAllKeyValues()
        {
            //Arrange
            var injectionWeather = new FakeWeatherObservationRepository();
            var weatherObj = new WeatherObservation(injectionWeather);

            var parameters = weatherObj.GetParameters().OrderBy(s=>s.Key);
            int count = 1;

            //Act &
            //Assert
            foreach (var parameter in parameters)
            {
                var temp = parameter.Key;
                Assert.AreEqual(temp, count++);
            }
        }
        public void WeatherObservation_Injected_Fake_MethodIs_GetParameterList_Assert_Live_and_Cache()
        {
            //Arrange
            var injectionWeather = new FakeCacheReturnsParameterModel();
            var injectionCache = new FakeCachedData();
            var weatherObj = new WeatherObservation(injectionWeather);

            ////Act
            var parametersNotCached = weatherObj.GetParameters().Select(model => model.Title).FirstOrDefault();

            var parametersFromCache = weatherObj.GetParameters().Select(model => model.Title).FirstOrDefault();

            //Assert
            Assert.AreNotEqual(parametersNotCached, parametersFromCache);
        }
 static Graph()
 {
     WeatherObj = new WeatherObservation();
     Stations = WeatherObj.GetWeatherStations(4);
 }
        /// <summary>
        /// ButtonSearch_click will search for weather station 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void ButtonSearch_OnClick(object sender, EventArgs e)
        {
            //Get weatherStation (taking windkey as parameter)
            var weatherObj = new WeatherObservation();
            var stations = weatherObj.GetWeatherStations(4);

            //input from user. weather station search
            var seachBoxValue = TextBoxSearchWindTemp.Text;

            try
            {
                _stationKey = (int)(from station in stations where station.Name.Contains(seachBoxValue) select station.Id).First();
            }
            catch
            {
                PlaceHolderError.Visible = true;
                LabelError.Text = "Ingen mätstation med det namnet hittades";
            }
        }