Beispiel #1
0
        public void SetApparentTemperature_ProperlySetsValue(float input, float expectedValue, TemperatureScale unit)
        {
            var builder = new WeatherDataBuilder();

            builder.SetApparentTemperature(input, unit);
            var data = builder.Build();

            Assert.Equal(expectedValue, data.TemperatureApparent.Value);
        }
Beispiel #2
0
        public void SetPressure_ProperlySetsValue()
        {
            var builder  = new WeatherDataBuilder();
            var pressure = 1010;

            builder.SetPressure(pressure);
            var data = builder.Build();

            Assert.Equal(pressure, data.Pressure);
        }
Beispiel #3
0
        public void SetDate_ProperlySetsValue()
        {
            var builder = new WeatherDataBuilder();
            var date    = new DateTime(2020, 01, 01, 10, 11, 1);

            builder.SetDate(date);
            var data = builder.Build();

            Assert.Equal(date, data.Date);
        }
Beispiel #4
0
        public void SetChanceOfRain_ProperlySetsValue()
        {
            var builder      = new WeatherDataBuilder();
            var chanceOfRain = 10;

            builder.SetChanceOfRain(chanceOfRain);
            var data = builder.Build();

            Assert.Equal(chanceOfRain, data.ChanceOfRain);
        }
Beispiel #5
0
        public void SetWeatherCode_ProperlySetsValue()
        {
            var builder     = new WeatherDataBuilder();
            var weatherCode = 200;

            builder.SetWeatherCode(weatherCode);
            var data = builder.Build();

            Assert.Equal(weatherCode, data.WeatherCode);
        }
Beispiel #6
0
        public void SetWindDirection_ProperlySetsValue()
        {
            var builder       = new WeatherDataBuilder();
            var windDirection = 110;

            builder.SetWindDirection(windDirection);
            var data = builder.Build();

            Assert.Equal(windDirection, data.WindDirection);
        }
Beispiel #7
0
        public void SetHumidity_ProperlySetsValue()
        {
            var builder  = new WeatherDataBuilder();
            var humidity = 56;

            builder.SetHumidity(humidity);
            var data = builder.Build();

            Assert.Equal(humidity, data.Humidity);
        }
Beispiel #8
0
        public void SetWindSpeed_KilometersPerHour_ProperlySetsValue()
        {
            var builder   = new WeatherDataBuilder();
            var windSpeed = 10;

            builder.SetWindSpeed(windSpeed, WindSpeedUnit.KilometersPerHour);

            var data = builder.Build();

            Assert.Equal(windSpeed, data.WindSpeed);
        }
Beispiel #9
0
        protected override WeatherData BuildWeatherDataFromDynamicObject(dynamic dynamicObject)
        {
            var builder = new WeatherDataBuilder();

            builder.SetMinTemperature((float)dynamicObject.min_temp, TemperatureScale.Celsius)
            .SetMaxTemperature((float)dynamicObject.max_temp, TemperatureScale.Celsius)
            .SetWeatherCode((int)dynamicObject.weather.code)
            .SetWeatherDescription((string)dynamicObject.weather.description)
            .SetChanceOfRain((int)dynamicObject.pop)
            .SetWindSpeed((float)dynamicObject.wind_spd, WindSpeedUnit.MetersPerSecond)
            .SetPressure((int)dynamicObject.slp)
            .SetDate(DateTime.Parse((string)dynamicObject.datetime));
            return(builder.Build());
        }
Beispiel #10
0
        protected override WeatherData BuildWeatherDataFromDynamicObject(dynamic o)
        {
            var builder = new WeatherDataBuilder();

            builder.SetDate((DateTime)o.Date)
            .SetMinTemperature((float)o.Temperature.Minimum.Value, TemperatureScale.Celsius)
            .SetMaxTemperature((float)o.Temperature.Maximum.Value, TemperatureScale.Celsius)
            .SetWindDirection((int)o.Day.Wind.Direction.Degrees)
            .SetWindSpeed((float)o.Day.Wind.Speed.Value, WindSpeedUnit.KilometersPerHour)
            .SetChanceOfRain((int)o.Day.PrecipitationProbability)
            .SetPrecipitationSummary((float)o.Day.TotalLiquid.Value)
            .SetWeatherCode((int)o.Day.Icon)
            .SetWeatherDescription((string)o.Day.IconPhrase);
            return(builder.Build());
        }
Beispiel #11
0
        protected override WeatherData BuildWeatherDataFromDynamicObject(dynamic o)
        {
            var builder = new WeatherDataBuilder();

            _ = builder.SetDate(_dateProvider.GetActualDateTime())
                .SetTemperature((float)o.temp, TemperatureScale.Celsius)
                .SetApparentTemperature((float)o.app_temp, TemperatureScale.Celsius)
                .SetWindDirection((int)o.wind_dir)
                .SetWindSpeed((float)o.wind_spd, WindSpeedUnit.MetersPerSecond)
                .SetPressure((int)o.slp)
                .SetHumidity((int)o.rh)
                .SetPrecipitationSummary((float)o.precip)
                .SetWeatherDescription((string)o.weather.description)
                .SetWeatherCode((int)o.weather.code);
            return(builder.Build());
        }
Beispiel #12
0
        protected override WeatherData BuildWeatherDataFromDynamicObject(dynamic dynamicObject)
        {
            var builder = new WeatherDataBuilder();

            builder
            .SetTemperature((float)dynamicObject.temp, TemperatureScale.Celsius)
            .SetApparentTemperature((float)dynamicObject.feels_like, TemperatureScale.Celsius)
            .SetHumidity((int)dynamicObject.humidity)
            .SetPressure((int)dynamicObject.pressure)
            .SetWindSpeed((float)dynamicObject.wind_speed, WindSpeedUnit.MetersPerSecond)
            .SetWindDirection((int)dynamicObject.wind_deg)
            .SetWeatherCode((int)dynamicObject.weather[0].id)
            .SetWeatherDescription((string)dynamicObject.weather[0].description)
            .SetDate(DateProvider.GetActualDateTime());
            return(builder.Build());
        }
Beispiel #13
0
        protected override WeatherData BuildWeatherDataFromDynamicObject(dynamic dynamicObject)
        {
            var builder = new WeatherDataBuilder();

            builder.SetTemperature((float)dynamicObject.Temperature.Metric.Value, TemperatureScale.Celsius)
            .SetApparentTemperature((float)dynamicObject.RealFeelTemperature.Metric.Value, TemperatureScale.Celsius)
            .SetHumidity((int)dynamicObject.RelativeHumidity)
            .SetWindDirection((int)dynamicObject.Wind.Direction.Degrees)
            .SetWindSpeed((float)dynamicObject.Wind.Speed.Metric.Value, WindSpeedUnit.KilometersPerHour)
            .SetPressure((int)dynamicObject.Pressure.Metric.Value)
            .SetPrecipitationSummary((float)dynamicObject.PrecipitationSummary.Precipitation.Metric.Value)
            .SetWeatherCode((int)dynamicObject.WeatherIcon)
            .SetWeatherDescription((string)dynamicObject.WeatherText)
            .SetDate(_dateProvider.GetActualDateTime());
            return(builder.Build());
        }
Beispiel #14
0
        protected override WeatherData BuildWeatherDataFromDynamicObject(dynamic dynamicObject)
        {
            var builder = new WeatherDataBuilder();

            builder
            .SetMinTemperature((float)dynamicObject.temp.min, TemperatureScale.Celsius)
            .SetMaxTemperature((float)dynamicObject.temp.max, TemperatureScale.Celsius)
            .SetChanceOfRain((int)((float)dynamicObject.pop * 100))
            .SetWeatherCode((int)dynamicObject.weather[0].id)
            .SetWeatherDescription((string)dynamicObject.weather[0].description)
            .SetWindSpeed((float)dynamicObject.wind_speed, WindSpeedUnit.MetersPerSecond)
            .SetWindDirection((int)dynamicObject.wind_deg)
            .SetDate(GetDateTimeFromUnixTimeStamp((long)dynamicObject.dt));

            return(builder.Build());
        }