public void LastLogBehaviourTest() { var mock = new Mock <IWebServiceHandler>(); mock.Setup(x => x.GetServiceRequestInfo()).Returns(NormalRequest); mock.Setup(x => x.ParseJSONObject(It.IsAny <string>())).Returns(HumidityData); WebWeather weather = new WebWeather(mock.Object); Assert.Null(weather.GetLastLog()); weather.FetchWeatherData(); var status = weather.GetLastLog(); Assert.NotNull(status); Assert.AreEqual(FetchWeatherStatus.Success, status.Status); }
public void ErrorHandlingTest() { var mock = new Mock <IWebServiceHandler>(); mock.Setup(x => x.GetServiceRequestInfo()).Returns(UnauthorizedRequest); WebWeather weather = new WebWeather(mock.Object); weather.FetchWeatherData(); var status = weather.GetLastLog(); Assert.NotNull(status); Assert.AreEqual(FetchWeatherStatus.Error, status.Status); }
public void ParseErrorDataTest() { var mock = new Mock <IWebServiceHandler>(); mock.Setup(x => x.GetServiceRequestInfo()).Returns(NormalRequest); mock.Setup(x => x.ParseJSONObject(It.IsAny <string>())).Returns((WeatherDataContainer?)null); WebWeather weather = new WebWeather(mock.Object); var data = weather.FetchWeatherData(); Assert.Null(data); var log = weather.GetLastLog(); Assert.NotNull(log); Assert.AreEqual(FetchWeatherStatus.Error, log.Status); }