Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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());
        }
Exemplo n.º 3
0
        public void GetStationDataWithEmptyStationNameExpectsNull()
        {
            // Arrange
            var weatherService = new WeatherService(new WeatherRepository(_datasourceMock.Object));

            // Action
            var result = weatherService.GetStationData(string.Empty);

            // Assert
            Assert.IsNull(result);
        }