public void ReturnFalse_AfterInvokingAction() { // TODO: Add the shim in here, because the test would pass regardless const int intervalInMinutes = 1; IRepository repository = new FakeRepo(); var currencyUpdate = new CurrencyUpdate(intervalInMinutes, new CurrencyGenerator(new List <IChatClient>(), new ChatUserCollection(repository))); bool result = false; currencyUpdate.Invoke(); result = currencyUpdate.IsTimeToRun(); Assert.False(result); }
public void ReturnFalse_AfterInvokingAction() { const int intervalInMinutes = 1; IRepository repository = new Mock <IRepository>().Object; var currencyGenerator = new CurrencyGenerator(new List <IChatClient>(), new ChatUserCollection(repository)); var fakeClock = new FakeClock(); var currencyUpdate = new CurrencyUpdate(intervalInMinutes, currencyGenerator, fakeClock); fakeClock.Now = fakeClock.Now.AddMinutes(intervalInMinutes); Assert.True(currencyUpdate.IsTimeToRun()); fakeClock.Now = fakeClock.Now.AddMinutes(intervalInMinutes); currencyUpdate.Invoke(); Assert.False(currencyUpdate.IsTimeToRun()); }
public void ReturnFalse_AfterInvokingAction() { const int intervalInMinutes = 1; var repository = new Mock <IRepository>(); repository.Setup(x => x.List(It.IsAny <ISpecification <ChatUser> >())).Returns(new List <ChatUser>()); var currencyGenerator = new CurrencyGenerator(new List <IChatClient>(), new ChatUserCollection(repository.Object)); var fakeClock = new FakeClock(); var currencyUpdate = new CurrencyUpdate(intervalInMinutes, currencyGenerator, fakeClock); fakeClock.Now = fakeClock.Now.AddMinutes(intervalInMinutes); Assert.True(currencyUpdate.IsTimeToRun()); fakeClock.Now = fakeClock.Now.AddMinutes(intervalInMinutes); currencyUpdate.Invoke(); Assert.False(currencyUpdate.IsTimeToRun()); }