public void Test_that_monitor_message_sends_to_the_slack()
        {
            // Arrange
            var manager = new LykkeLogToAzureSlackNotificationsManager(_slackNotificationsSenderMock);

            manager.Start();

            // Act
            manager.SendNotification(LogEntity.CreateWithoutRowKey(LykkeLogToAzureStorage.MonitorType, "Test", "", "", null, null, "Message", DateTime.UtcNow));

            // Assert
            manager.Stop();

            _slackNotificationsSenderMock.Received().SendAsync(Arg.Is <string>(t => t == "Monitor"), Arg.Any <string>(), Arg.Any <string>());
        }
Ejemplo n.º 2
0
        public void TestSlackManagerPreventsSameMessageSpamWithDefaultConfiguration()
        {
            // Arrange
            var manager = new LykkeLogToAzureSlackNotificationsManager(_slackNotificationsSenderMock);

            manager.Start();
            var logEntry = LogEntity.CreateWithoutRowKey(
                LykkeLogToAzureStorage.WarningType, "Component", "Process", "Context", null, null, "Message", DateTime.UtcNow);

            // Act
            manager.SendNotification(logEntry);
            manager.SendNotification(logEntry);

            //Assert
            _slackNotificationsSenderMock.Received().SendAsync(Arg.Is <string>(t => t == "Warning"), Arg.Any <string>(), Arg.Any <string>());
        }
Ejemplo n.º 3
0
        public void TestSlackManagerAllowsSameMessageSpamAfterTimeoutWithCustomConfiguration()
        {
            var mutePeriod = TimeSpan.FromSeconds(2);
            // Arrange
            var manager = new LykkeLogToAzureSlackNotificationsManager(_slackNotificationsSenderMock)
                          .SetSpamMutePeriodForLevels(mutePeriod, LogLevel.Warning);

            manager.Start();
            var logEntry = LogEntity.CreateWithoutRowKey(
                LykkeLogToAzureStorage.WarningType, "Component", "Process", "Context", null, null, "Message", DateTime.UtcNow);

            // Act
            manager.SendNotification(logEntry);
            Thread.Sleep(mutePeriod);
            manager.SendNotification(logEntry);

            //Assert
            _slackNotificationsSenderMock.Received(2).SendAsync(Arg.Is <string>(t => t == "Warning"), Arg.Any <string>(), Arg.Any <string>());
        }