public void FakeTimeProviderSetValueTest() { var testTime = new DateTime(2000, 01, 27, 12, 55, 57); var provider = new FakeTimeProvider(); Assert.AreNotEqual(testTime, provider.UtcNow); provider.SetTime(testTime); Assert.AreEqual(testTime, provider.UtcNow); }
public void UnorderedReceiverState_should_prune_older_senders_correctly() { var confirmable = new ConfirmableMessageEnvelope(1L, "foo", "bar"); var timeProvider = new FakeTimeProvider(DateTime.UtcNow); var receiverState = new UnorderedReceiverState(timeProvider); receiverState.ConfirmProcessing(confirmable.ConfirmationId, confirmable.SenderId); timeProvider.SetTime(TimeSpan.FromSeconds(10)); var prune = receiverState.Prune(TimeSpan.FromSeconds(5)); prune.prunedSenders.Should().BeEquivalentTo("foo"); }
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)); }