public void SubtractsTheUserConfiguredTimeSpanFromTheEventsStartDate(long ticks) { if (ticks < 0) { return; } var timeSpan = TimeSpan.FromTicks(ticks); var now = new DateTimeOffset(2020, 1, 1, 0, 0, 0, TimeSpan.Zero); var endOfWeek = now.AddDays(7); var eightHours = TimeSpan.FromHours(8); var events = Enumerable .Range(0, 14) .Select(number => new CalendarItem( id: number.ToString(), source: CalendarItemSource.Calendar, startTime: now.Add(eightHours * number), duration: eightHours, description: number.ToString(), iconKind: CalendarIconKind.None, calendarId: "1" )); var expectedNotifications = events .Where(calendarItem => calendarItem.StartTime >= now + timeSpan) .Select(@event => new Notification( @event.Id, "Event reminder", @event.Description, @event.StartTime - timeSpan )); UserPreferences .TimeSpanBeforeCalendarNotifications .Returns(Observable.Return(timeSpan)); UserPreferences .EnabledCalendarIds() .Returns(new List <string> { "1" }); CalendarService .GetEventsInRange(now, endOfWeek) .Returns(Observable.Return(events)); TimeService.CurrentDateTime.Returns(now); NotificationService.ClearReceivedCalls(); interactor.Execute().Wait(); NotificationService .Received() .Schedule(Arg.Is <IImmutableList <Notification> >( notifications => notifications.SequenceEqual(expectedNotifications)) ); }
public override void Before() { GivenTheColdSpellTemperatureIs(ColdSpellTemp); Handler.HandleAsync(CreateTemperatureTelemetry(-5.0)).Wait(); // Cold Spell begin Handler.HandleAsync(CreateTemperatureTelemetry(3.1)).Wait(); // Cold Spell end Handler.HandleAsync(CreateTemperatureTelemetry(2.9)).Wait(); // Cold Spell begin NotificationService.ClearReceivedCalls(); NotificationService.RaiseAsync(Arg.Do <NotificationMessage>(n => _capturedNotification = n)); }
public override void Before() { const double currentTemp = 2.9; GivenTheColdSpellTemperatureIs(ColdSpellTemp); var telemetry = CreateTemperatureTelemetry(currentTemp); telemetry.Timestamp = _enteredAtUtc; Handler.HandleAsync(telemetry).Wait(); NotificationService.ClearReceivedCalls(); NotificationService.RaiseAsync(Arg.Do <NotificationMessage>(n => _capturedNotification = n)); }