public void CashedResultWeatherViewDataSourceGetWeatherDataProvidersNotCashTest() { var weatherDataProviders = new[] { new Mock<IDataProviderInfo>().Object }; var mockSource = new Mock<IWeatherViewDataSource>(); mockSource.Setup(t => t.GetWeatherDataProviders()).Returns(weatherDataProviders); var timeProvider = new FakeTimeProvider(DateTime.Now); TimeProvider.Current = timeProvider; var provider = new CashedResultWeatherViewDataSource(mockSource.Object, 100); provider.GetWeatherDataProviders(); timeProvider.SetTime(timeProvider.UtcNow.AddSeconds(101)); provider.GetWeatherDataProviders(); mockSource.Verify(t => t.GetWeatherDataProviders(), Times.Exactly(2)); }
public void CashedResultWeatherViewDataSourceGetWeatherInfoNotCashTest() { const string testName = "testName"; var resultWeatherInfo = new Mock<ICityWeatherInfo>(); var mockSource = new Mock<IWeatherViewDataSource>(); mockSource.Setup(t => t.GetWeatherInfo(It.IsAny<string>())).Returns(resultWeatherInfo.Object); var timeProvider = new FakeTimeProvider(DateTime.Now); TimeProvider.Current = timeProvider; var provider = new CashedResultWeatherViewDataSource(mockSource.Object, 100); provider.ClearCash(); provider.GetWeatherInfo(testName); timeProvider.SetTime(timeProvider.UtcNow.AddSeconds(101)); provider.GetWeatherInfo(testName); mockSource.Verify(t => t.GetWeatherInfo(It.Is<string>(k=>k== testName)), Times.Exactly(2)); }