public void TestGeneralTimeCurrentWeatherEmptyForecast() { DateTimeRange range = SamiDateTime.GetDateTimeRange(DateTime.Now); Dictionary <String, String> input = new Dictionary <string, string> { { "Command", "weather" }, { "Location", "here" }, { "Time", String.Format("DayOfWeek=today;TimeOfDay={0};", range.ToString().ToLower()) }, }; IConfigurationManager configMan = GetConfigurationManager(); Mock <IWeatherSensor> weatherSensor = new Mock <IWeatherSensor>(MockBehavior.Strict); weatherSensor.Setup(s => s.Name).Returns("Mock Weather Sensor"); weatherSensor.Setup(s => s.IsValid).Returns(true); DateTime today = DateTime.Now; SamiDateTime samiTime = new SamiDateTime(today, range); WeatherCondition minForecast = new WeatherCondition(DateTime.Now, 70, "Rainy"); weatherSensor.Setup(s => s.LoadConditions(new Location("Austin", "Texas", 78759))).Returns(minForecast); weatherSensor.Setup(s => s.LoadHourlyForecasts(new Location("Austin", "Texas", 78759))).Returns(new List <WeatherCondition>()); AddComponentToConfigurationManager(weatherSensor.Object); Assert.AreEqual("That forecast is not available currently.", RunSingleConversation <WeatherConversation>(input)); weatherSensor.Verify(s => s.LoadConditions(new Location("Austin", "Texas", 78759)), Times.Exactly(1)); weatherSensor.Verify(s => s.LoadHourlyForecasts(new Location("Austin", "Texas", 78759)), Times.Exactly(1)); }
public void TestGeneralTimeCurrentWeatherStayAtSuccess() { DateTimeRange range = SamiDateTime.GetDateTimeRange(DateTime.Now); Dictionary <String, String> input = new Dictionary <string, string> { { "Command", "weather" }, { "Location", "here" }, { "Time", String.Format("DayOfWeek=today;TimeOfDay={0};", range.ToString().ToLower()) }, }; IConfigurationManager configMan = GetConfigurationManager(); Mock <IWeatherSensor> weatherSensor = new Mock <IWeatherSensor>(MockBehavior.Strict); weatherSensor.Setup(s => s.Name).Returns("Mock Weather Sensor"); weatherSensor.Setup(s => s.IsValid).Returns(true); DateTime today = DateTime.Now; SamiDateTime samiTime = new SamiDateTime(today, range); WeatherCondition minForecast = new WeatherCondition(DateTime.Now, 70, "Rainy"); WeatherCondition maxForecast = new WeatherCondition(samiTime.GetMaxTime(), 70, "Sunny"); weatherSensor.Setup(s => s.LoadConditions(new Location("Austin", "Texas", 78759))).Returns(minForecast); weatherSensor.Setup(s => s.LoadHourlyForecasts(new Location("Austin", "Texas", 78759))).Returns(new List <WeatherCondition> { maxForecast }); AddComponentToConfigurationManager(weatherSensor.Object); String expectedResult = String.Format("According to Mock Weather Sensor. Currently, it is 70 degrees and Rainy. It will stay at 70 degrees by {0} and Sunny..", samiTime.GetMaxTime().ToString("hh:mm tt", CultureInfo.InvariantCulture)); Assert.AreEqual(expectedResult, RunSingleConversation <WeatherConversation>(input)); weatherSensor.Verify(s => s.LoadConditions(new Location("Austin", "Texas", 78759)), Times.Exactly(1)); weatherSensor.Verify(s => s.LoadHourlyForecasts(new Location("Austin", "Texas", 78759)), Times.Exactly(1)); }
public void TestGeneralTimeCurrentWeatherFailInPast() { DateTimeRange range = SamiDateTime.GetDateTimeRange(DateTime.Now); Dictionary <String, String> input = new Dictionary <string, string> { { "Command", "weather" }, { "Location", "here" }, { "Time", String.Format("DayOfWeek=yesterday;TimeOfDay={0};", range.ToString().ToLower()) }, }; IConfigurationManager configMan = GetConfigurationManager(); Mock <IWeatherSensor> weatherSensor = new Mock <IWeatherSensor>(MockBehavior.Strict); weatherSensor.Setup(s => s.Name).Returns("Mock Weather Sensor"); weatherSensor.Setup(s => s.IsValid).Returns(true); AddComponentToConfigurationManager(weatherSensor.Object); Assert.AreEqual("I'm sorry, I can not get a forcast for the past.", RunSingleConversation <WeatherConversation>(input)); }