public async Task CheckForNotificationsAsync_ReturnsNullWithHealthyNotificationAndIsCurrentlySuccess() { // Arrange using (var tc = new TestContext()) { tc.AddCheckNotification(true); tc.AddCheckResult(CheckResultType.Success, 0); // Act var notification = await tc.Target.CheckForNotificationAsync(tc.CheckName, tc.Token); // Assert Assert.Null(notification); } }
public async Task CheckForNotificationsAsync_ReturnsNullWithUnhealthyNotificationAndEnoughFailures() { // Arrange using (var tc = new TestContext()) { tc.AddCheckNotification(false); tc.AddCheckResult(CheckResultType.Failure, -2); tc.AddCheckResult(CheckResultType.Failure, -1); tc.AddCheckResult(CheckResultType.Failure, 0); // Act var notification = await tc.Target.CheckForNotificationAsync(tc.CheckName, tc.Token); // Assert Assert.Null(notification); } }
public async Task CheckForNotificationsAsync_UpdatesNotificationWithUnhealthNotificationAndIsCurrentlySuccess() { // Arrange using (var tc = new TestContext()) { var existing = tc.AddCheckNotification(false); var success = tc.AddCheckResult(CheckResultType.Success, 0); // Act var notification = await tc.Target.CheckForNotificationAsync(tc.CheckName, tc.Token); // Assert Assert.NotNull(notification); Assert.True(notification.IsHealthy); Assert.Equal(success.CheckResultId, notification.CheckResultId); Assert.Equal(tc.UtcNow, notification.Time); Assert.Equal(2, notification.Version); Assert.Equal(existing.CheckNotificationId, notification.CheckNotificationId); } }
public async Task CheckForNotificationsAsync_UpdatesNotificationWithHealthNotificationAndEnoughFailures() { // Arrange using (var tc = new TestContext()) { var existing = tc.AddCheckNotification(true); var oldest = tc.AddCheckResult(CheckResultType.Failure, -2); tc.AddCheckResult(CheckResultType.Failure, -1); tc.AddCheckResult(CheckResultType.Failure, 0); // Act var notification = await tc.Target.CheckForNotificationAsync(tc.CheckName, tc.Token); // Assert Assert.NotNull(notification); Assert.False(notification.IsHealthy); Assert.Equal(oldest.CheckResultId, notification.CheckResultId); Assert.Equal(tc.UtcNow, notification.Time); Assert.Equal(2, notification.Version); Assert.Equal(existing.CheckNotificationId, notification.CheckNotificationId); } }