/// <summary> /// Merges the specified <see cref="SportEventConditionsDTO"/> into instance /// </summary> /// <param name="dto">A <see cref="SportEventConditionsDTO"/> containing information about the sport event conditions</param> /// <param name="culture">A <see cref="CultureInfo"/> specifying the language of the sport event conditions</param> internal void Merge(SportEventConditionsDTO dto, CultureInfo culture) { Guard.Argument(dto, nameof(dto)).NotNull(); Guard.Argument(culture, nameof(culture)).NotNull(); Attendance = dto.Attendance; EventMode = dto.EventMode; if (dto.Referee != null) { if (Referee == null) { Referee = new RefereeCI(dto.Referee, culture); } else { Referee.Merge(dto.Referee, culture); } } if (dto.WeatherInfo != null) { WeatherInfo = new WeatherInfoCI(dto.WeatherInfo); } if (dto.Pitchers != null) { Pitchers = dto.Pitchers.Select(s => new PitcherCI(s, culture)); } }
/// <summary> /// Merges the specified <see cref="SportEventConditionsDTO" /> into instance /// </summary> /// <param name="dto">A <see cref="SportEventConditionsDTO" /> containing information about the sport event conditions</param> /// <param name="culture">A <see cref="CultureInfo" /> specifying the language of the sport event conditions</param> internal void Merge(SportEventConditionsDTO dto, CultureInfo culture) { Contract.Requires(dto != null); Contract.Requires(culture != null); Attendance = dto.Attendance; EventMode = dto.EventMode; if (dto.Referee != null) { if (Referee == null) { Referee = new RefereeCI(dto.Referee, culture); } else { Referee.Merge(dto.Referee, culture); } } if (dto.WeatherInfo != null) { WeatherInfo = new WeatherInfoCI(dto.WeatherInfo); } if (dto.Pitchers != null) { Pitchers = dto.Pitchers.Select(s => new PitcherCI(s, culture)); } }
/// <summary> /// Initializes a new instance of the <see cref="SportEventConditions"/> class /// </summary> /// <param name="dto">A <see cref="SportEventConditionsDTO"/> used to create new instance</param> /// <param name="culture">A <see cref="CultureInfo"/> specifying the language of the sport event conditions</param> internal SportEventConditionsCI(SportEventConditionsDTO dto, CultureInfo culture) { Guard.Argument(dto, nameof(dto)).NotNull(); Guard.Argument(culture, nameof(culture)).NotNull(); Merge(dto, culture); }
/// <summary> /// Initializes a new instance of the <see cref="SportEventConditions" /> class /// </summary> /// <param name="dto">A <see cref="SportEventConditionsDTO" /> used to create new instance</param> /// <param name="culture">A <see cref="CultureInfo" /> specifying the language of the sport event conditions</param> internal SportEventConditionsCI(SportEventConditionsDTO dto, CultureInfo culture) { Contract.Requires(dto != null); Contract.Requires(culture != null); Merge(dto, culture); }
public void SportEventConditionsTest() { var venue1 = new venue { id = "sr:venue:1", capacity = 1, capacitySpecified = true, city_name = "my city", country_name = "my country", map_coordinates = "coordinates", name = "venue name", }; var weatherInfo1 = new weatherInfo { pitch = "my pitch", temperature_celsius = 40, temperature_celsiusSpecified = true, weather_conditions = "my weather conditions", wind = "strong", wind_advantage = "none" }; var sportEventConditionType = new sportEventConditions { attendance = "all", match_mode = "full mode", referee = new referee { id = "sr:referee:1", name = "John Doe", nationality = "German", }, venue = venue1, weather_info = weatherInfo1 }; var sportEventConditionsDTO = new SportEventConditionsDTO(sportEventConditionType); var sportEventConditionsCI = new SportEventConditionsCI(sportEventConditionsDTO, _cultureFirst); Assert.IsNotNull(sportEventConditionsCI); Assert.AreEqual(sportEventConditionType.attendance, sportEventConditionsCI.Attendance); Assert.AreEqual(sportEventConditionType.match_mode, sportEventConditionsCI.EventMode); Assert.AreEqual(sportEventConditionType.referee.id, sportEventConditionsCI.Referee.Id.ToString()); Assert.AreEqual(sportEventConditionType.referee.name, sportEventConditionsCI.Referee.Name); Assert.AreEqual(sportEventConditionType.referee.nationality, sportEventConditionsCI.Referee.GetNationality(_cultureFirst)); //Assert.AreEqual(sportEventConditionType.venue.id, sportEventConditionsCI.); TODO: missing Venue Assert.AreEqual(sportEventConditionType.weather_info.pitch, sportEventConditionsCI.WeatherInfo.Pitch); Assert.AreEqual(sportEventConditionType.weather_info.temperature_celsius, sportEventConditionsCI.WeatherInfo.TemperatureCelsius); Assert.AreEqual(sportEventConditionType.weather_info.weather_conditions, sportEventConditionsCI.WeatherInfo.WeatherConditions); Assert.AreEqual(sportEventConditionType.weather_info.wind, sportEventConditionsCI.WeatherInfo.Wind); Assert.AreEqual(sportEventConditionType.weather_info.wind_advantage, sportEventConditionsCI.WeatherInfo.WindAdvantage); }