public void ShouldLoadSearchOporto()
 {
     using (WeatherWebApi api = new WeatherWebApi())
     {
         IEnumerable <LocationInfo> locals = api.Search("oporto");
         Assert.AreEqual(6, locals.Count());
         Assert.AreEqual("Cuba", locals.ElementAt(5).Country);
     }
 }
Exemplo n.º 2
0
 public void TestLoadSearchOporto()
 {
     using (WeatherWebApi api = new WeatherWebApi())
     {
         LocationInfo[] locals = api.Search("oporto");
         Assert.AreEqual(6, locals.Length);
         Assert.AreEqual("Cuba", locals[5].Country);
     }
 }
Exemplo n.º 3
0
 public void TestLoadPastWeatherOnJanuaryAndCheckMaximumTempC()
 {
     using (WeatherWebApi api = new WeatherWebApi())
     {
         IEnumerable <WeatherInfo> infos = api.PastWeather(37.017, -7.933, DateTime.Parse("2019-01-01"), DateTime.Parse("2019-01-30"));
         int max = int.MinValue;
         foreach (WeatherInfo wi in infos)
         {
             if (wi.TempC > max)
             {
                 max = wi.TempC;
             }
         }
         Assert.AreEqual(19, max);
         // Console.WriteLine(String.Join("\n", infos));
     }
 }
Exemplo n.º 4
0
        public void TestLoadSearchOportoOnRequestMock()
        {
            Mocker mocker = new Mocker(typeof(IHttpRequest));

            mocker.When("GetBody")
            .With(oportoSearchUrl)
            .Return(oportoSearchBody);
            mocker
            .When("Dispose").Then(() => { }).With();

            IHttpRequest req = (IHttpRequest)mocker.Create();

            using (IWeatherWebApi api = new WeatherWebApi(req))
            {
                IEnumerable <LocationInfo> locals = api.Search("oporto");
                Assert.AreEqual(6, locals.Count());
                Assert.AreEqual("Cuba", locals.ElementAt(5).Country);
            }
        }
 public void ShouldCheckPastWeatherOnJanuaryAndMaximumTempC()
 {
     //Arrange
     using (WeatherWebApi api = new WeatherWebApi())
     {
         IEnumerable <WeatherInfo> infos = api.PastWeather(37.017, -7.933, DateTime.Parse("2019-01-01", CultureInfo.CreateSpecificCulture("pt-PT"), DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeLocal), DateTime.Parse("2019-01-30", CultureInfo.CreateSpecificCulture("pt-PT"), DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeLocal));
         //Act
         int max = int.MinValue;
         foreach (WeatherInfo wi in infos)
         {
             if (wi.TempC > max)
             {
                 max = wi.TempC;
             }
         }
         //Assert
         Assert.AreEqual(19, max);
     }
 }