Example #1
0
 public WeatherChecker(
     IUnitOfMeasurementsService measurements,
     IOptions <List <WeatherProvider> > providers)
 {
     this.measurements = measurements ?? throw new ArgumentNullException(nameof(measurements));
     this.providers    = providers?.Value ?? throw new ArgumentNullException(nameof(providers));
 }
        public WeatherCheckResponse(WeatherProvider provider, string location, IUnitOfMeasurementsService measurements)
        {
            Provider = provider;
            Location = location;

            temperatureUnit = measurements.TemperatureUnits.Single(t => t.Id == Provider.TemperatureUnitId);
            windSpeedUnit   = measurements.WindSpeedUnits.Single(w => w.Id == provider.WindSpeedUnitId);
        }
Example #3
0
 public HomeController(
     IUnitOfMeasurementsService measurements,
     IWeatherChecker weatherChecker)
 {
     this.measurements = measurements
                         ?? throw new ArgumentNullException(nameof(measurements));
     this.weatherChecker = weatherChecker
                           ?? throw new ArgumentNullException(nameof(weatherChecker));
 }
Example #4
0
 internal static IEnumerable <WeatherCheckResponse> Responses(
     IUnitOfMeasurementsService measurements,
     double cel = 10.0,
     double far = 68.0,
     double kph = 8.0,
     double mph = 10.0) => new List <WeatherCheckResponse>
 {
     new WeatherCheckResponse(Providers.First(), "bournemouth", measurements)
     {
         Temperature = new Measurement(Temperature.Single(t => t.Id == Cel), cel),
         WindSpead   = new Measurement(WindSpeed.Single(t => t.Id == Kph), kph)
     },
     new WeatherCheckResponse(Providers.Last(), "bournemouth", measurements)
     {
         Temperature = new Measurement(Temperature.Single(t => t.Id == Far), far),
         WindSpead   = new Measurement(WindSpeed.Single(t => t.Id == Mph), mph)
     }
 };
 public UnitOfMeasureViewComponent(IUnitOfMeasurementsService measurements) =>
 this.measurements = measurements ?? throw new ArgumentNullException(nameof(measurements));