public void HasCorrectValues(string dtStr, string expectedStr) { var dt = DateTime.Parse(dtStr); var expected = this.Parse(expectedStr); var actual = _service.Get(dt); Assert.Equal(expected.Time, actual.Time); Assert.Equal(expected.DayOfWeek, actual.DayOfWeek); Assert.Equal(expected.DayOfMonthEnglish, actual.DayOfMonthEnglish); Assert.Equal(expected.Month, actual.Month); Assert.Equal(expected.PartOfDay, actual.PartOfDay); }
public async Task <GreetingResult> GetGreeting(IGreetingRequest req) { var now = DateTime.UtcNow.UtcToPst(); var readableNow = _readableDateTimeService.Get(now); var msgTasks = new[] { req.Greeting?Task.FromResult($"Good {readableNow.PartOfDay} {req.Name}".Trim() + "!") : DefaultMsg(), req.Date ? Task.FromResult($"It's {readableNow.DayOfWeek} {readableNow.Month} {readableNow.DayOfMonthEnglish} {readableNow.Time}.") : DefaultMsg(), req.Weather ? _weatherService.GetWeatherMessage(req.Zip) : DefaultMsg(), req.Surf.HasValue ? _surfService.GetCurrentSurfMessage(req.Surf.Value) : DefaultMsg(), req.Water ? _surfService.GetCurrentOceanTemperatureMessage(SurfCounty.SanDiego) : DefaultMsg(), req.News ? _newsService.GetHeadlinesMessage() : DefaultMsg() }; await Task.WhenAll(msgTasks); var msg = string.Join(" ", msgTasks.Select(t => t.Result)); return(new GreetingResult { Message = msg.Trim() }); }
public string GetForecastInstanceMsg(string prefix, string weatherChangePhrase, ForecastList forecastInstance) { var readableLaterTime = _readableDateTimeService.Get(forecastInstance.DateTimePst); return($"{prefix} {readableLaterTime.Time} It will {weatherChangePhrase} {forecastInstance.Main.Temp} degrees with {forecastInstance.Weather.FirstOrDefault().Description}. "); }