public void RepeatedChecksGiveExpectedBehaviour() { var moodChangeEvery = 10; var startFrom = DateTime.Now; var actionStatus = new ActionStatus { LastAction = startFrom, LastChecked = startFrom, SatisfactionLevel = SatisfactionLevel.Neutral }; for (var i = 0; i <= 20; i++) { var compareWith = startFrom.AddSeconds(i); var mockTime = new Mock <ITimeService>(); mockTime.Setup(x => x.GetCurrentTime()).Returns(compareWith); var elapsedService = new ElapsedService(mockTime.Object); var satisfactionService = new SatisfactionService(elapsedService, mockTime.Object); actionStatus = satisfactionService.Check(actionStatus, moodChangeEvery); } actionStatus.SatisfactionLevel.Should().Be(SatisfactionLevel.VeryBad); }
public void MoodChangesAsExpected() { var startFrom = DateTime.Now; var compareWith = startFrom.AddSeconds(_secondsSinceLastInteraction); var mockTime = new Mock <ITimeService>(); mockTime.Setup(x => x.GetCurrentTime()).Returns(compareWith); var elapsedService = new ElapsedService(mockTime.Object); var satisfactionService = new SatisfactionService(elapsedService, mockTime.Object); var actionStatus = new ActionStatus { LastAction = startFrom, LastChecked = startFrom, SatisfactionLevel = _startLevel }; actionStatus = satisfactionService.Perform(actionStatus, _moodChangeEvery); actionStatus.SatisfactionLevel.Should().Be(_expectedLevel); // Check again, expect no change actionStatus.SatisfactionLevel.Should().Be(_expectedLevel); }