/// <summary> /// Controller action developed using the the Bridge design pattern to get its data /// </summary> /// <remarks> /// This controller is programmed against the interface IWeatherClient, so it avoids the direct /// dependency on a third party interface. /// </remarks> /// <param name="zipCode">A String of the zip code to get the weather for</param> /// <returns></returns> public ActionResult BridgePattern(String zipCode = null) { if (String.IsNullOrWhiteSpace(zipCode)) { zipCode = "53211"; } IWeatherClient weatherClient = new WeatherUndergroundDriver(); #region NOAA Weather Client //IWeatherClient weatherClient = new NoaaWeatherAdapter.NoaaWeatherDriver(this.zipCodeService); #endregion #region Fake Weather Service // IWeatherClient weatherClient = new FakeWeatherServiceDriver(); #endregion #region Caching Decorator //IWeatherClient weatherClient = new WeatherClientCacheDecorator(new WeatherUndergroundDriver()); #endregion CurrentConditions currentConditions = weatherClient.GetCurrentConditions(zipCode); BridgePatternModel model = new BridgePatternModel() { WeatherData = currentConditions }; return(View(model)); }
public void TestWindchillConversionWithBadValues(String value) { // Arrange WeatherUndergroundDriver wuDriver = new WeatherUndergroundDriver(); // Act double?windchill = wuDriver.ConvertWindchillString(value); // Assert Assert.Null(windchill); }