protected override void Before() { Configuration.SmsFrom.Returns(From); Configuration.SmsTo.Returns(To); ColdSpellRepository.GetAsync(Arg.Any <string>(), Arg.Any <string>()) .Returns(Task.FromResult <ColdSpell>(null)); DateTimeProvider.UtcNow().Returns(_utcNow); }
protected override void Before() { var coldSpell = new ColdSpell { AlertedAt = _lastAlertedAt }; ColdSpellRepository.GetAsync(Arg.Any <string>(), Arg.Any <string>()).Returns(Task.FromResult(coldSpell)); DateTimeProvider.UtcNow().Returns(_lastAlertedAt.AddHours(6)); }
protected override void Before() { Configuration.SmsFrom.Returns(From); Configuration.SmsTo.Returns(To); var coldSpell = new ColdSpell { AlertedAt = _lastAlertedAt }; ColdSpellRepository.GetAsync(Arg.Any <string>(), Arg.Any <string>()).Returns(Task.FromResult(coldSpell)); DateTimeProvider.UtcNow().Returns(_utcNow); }
public async Task When_Notification_Is_Handled_Then_Should_Send_Sms() { const double currentTemp = 1.5; const double coldSpellTemp = 2.0; var enteredAtUtc = new DateTime(2015, 1, 1, 12, 0, 0, DateTimeKind.Utc); var notification = CreateNotification(currentTemp, coldSpellTemp, enteredAtUtc); await Handler.HandleAsync(notification); SmsClient.Received().Send(From, To, "12:00: Entered cold spell. (Temp: 1.5C)."); ColdSpellRepository.Received().SaveAsync(Arg.Is <ColdSpell>(cs => cs.AlertedAt == _utcNow)); }
public async Task When_Notification_Is_Handled_Then_Should_Add_Entity_To_Repository() { const double currentTemp = 1.5; const double coldSpellTemp = 2.0; var enteredAtUtc = new DateTime(2015, 1, 1, 12, 0, 0, DateTimeKind.Utc); var notification = CreateNotification(currentTemp, coldSpellTemp, enteredAtUtc); await Handler.HandleAsync(notification); ColdSpellRepository.Received().SaveAsync(Arg.Is <ColdSpell>(cs => cs.AlertedAt == _utcNow && cs.DeviceId == DeviceId && cs.SensorId == SensorId)); }