public void GetStationDataWithCorrectDataExpectsDataReturn() { // Arrange _datasourceMock.Setup(x => x.BuildDataSource<Observations>()) .Returns(new Observations { Observation = new[] { new Observation { StationName = "Station Name 1", DateTime = new DateTime(2013, 4, 11) } } }); var weatherService = new WeatherService(new WeatherRepository(_datasourceMock.Object)); // Action var result = weatherService.GetStationData("Station Name 1"); // Assert Assert.AreEqual(1, result.Count()); Assert.AreEqual("Station Name 1", result.FirstOrDefault().StationName); Assert.AreEqual(new DateTime(2013, 4, 11), result.FirstOrDefault().DateTime); }
public void GetStationDataWithDummyStationNameExpectsNoObjectReturn() { // Arrange _datasourceMock.Setup(x => x.BuildDataSource<Observations>()) .Returns(new Observations { Observation = new[] { new Observation { StationName = "Station Name 1", DateTime = new DateTime(2013, 4, 11) } } }); var weatherService = new WeatherService(new WeatherRepository(_datasourceMock.Object)); // Action var result = weatherService.GetStationData("This is dummy station"); // Assert Assert.AreEqual(0, result.Count()); }
public void GetStationDataWithEmptyStationNameExpectsNull() { // Arrange var weatherService = new WeatherService(new WeatherRepository(_datasourceMock.Object)); // Action var result = weatherService.GetStationData(string.Empty); // Assert Assert.IsNull(result); }