Exemplo n.º 1
0
        public async Task CheckForNotificationsAsync_ReturnsNullWithNoNotificationAndNotEnoughFailures()
        {
            // Arrange
            using (var tc = new TestContext())
            {
                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.º 2
0
        public async Task CheckForNotificationsAsync_ReturnsNullWithFailuresThatAreTooOld()
        {
            // Arrange
            using (var tc = new TestContext())
            {
                tc.AddCheckResult(CheckResultType.Failure, -16);
                tc.AddCheckResult(CheckResultType.Failure, -15);
                tc.AddCheckResult(CheckResultType.Failure, -14); // This one should be found by the query.

                // Act
                var notification = await tc.Target.CheckForNotificationAsync(tc.CheckName, tc.Token);

                // Assert
                Assert.Null(notification);
            }
        }
Exemplo n.º 3
0
        public async Task CheckForNotificationsAsync_AddsNotificationWithNoNotificationAndEnoughFailures()
        {
            // Arrange
            using (var tc = new TestContext())
            {
                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(1, notification.Version);
            }
        }
Exemplo n.º 4
0
        public async Task CheckForNotificationsAsync_ReturnsNullWithNoNotificationAndIsCurrentlySuccess()
        {
            // Arrange
            using (var tc = new TestContext())
            {
                tc.AddCheckResult(CheckResultType.Success, 0);

                // Act
                var notification = await tc.Target.CheckForNotificationAsync(tc.CheckName, tc.Token);

                // Assert
                Assert.Null(notification);
            }
        }
Exemplo n.º 5
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);
            }
        }