示例#1
0
        public async void CurrentAnd7DaysForecastWorksCorrectly()
        {
            // prepare
            Forecast output = null;

            using (var stream = new BufferedStream(File.OpenRead("./Resources/DarkSky_CurrentAnd7DaysForecast_SI.json"), 8192)) {
                var mockHttp = new MockHttpMessageHandler();
                mockHttp
                .When(DarkSkyService.EndPointRoot + "*")
                .Respond("application/json", stream);
                IDarkSkyService client = new DarkSkyService("a_valid_key", mockHttp);

                var exclusionList = new List <Exclude> {
                    Exclude.Hourly, Exclude.Minutely, Exclude.Alerts, Exclude.Flags
                };
                output = await client.GetWeather(BolognaLatitude, BolognaLongitude, null, exclusionList, DSUnit.Auto, Language.Italian);

                stream.Close();
            }

            // assert
            Assert.NotNull(output);
            Assert.NotNull(output.Currently);
            Assert.Null(output.Minutely);
            Assert.Null(output.Hourly);
            Assert.NotNull(output.Currently);
            Assert.NotNull(output.Daily);
            Assert.NotNull(output.Daily.Data);
            Assert.NotEmpty(output.Daily.Data);
        }