Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
        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);
            }
        }
Exemplo n.º 4
0
        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);
            }
        }