Example #1
0
        public async Task NotifyException_PayloadIsStackTrace(Exception dummy)
        {
            var settings = _fixture.Build <ApplicationSettings>()
                           .WithAutoProperties()
                           .With(f => f.SlackWebhook, MOCK_HOOK)
                           .Create();

            var _sut = new SlackResultNotifier(settings);

            await _sut.NotifyUnhandledException(dummy);

            _http.ShouldHaveCalled(MOCK_HOOK)
            .WithVerb(HttpMethod.Post)
            .WithJsonProperty <string>(b => b.attachments[0].text, $"```csharp\n{dummy.ToString()}\n```");
        }
Example #2
0
        public async Task NotifyException_TitleLinkForcesHttpsIfMissingProto(Exception dummy)
        {
            var settings = _fixture.Build <ApplicationSettings>()
                           .WithAutoProperties()
                           .With(f => f.SlackWebhook, MOCK_HOOK)
                           .With(f => f.Endpoint, "hcr.mydomain.net")
                           .Create();

            var _sut = new SlackResultNotifier(settings);

            await _sut.NotifyUnhandledException(dummy);

            _http.ShouldHaveCalled(MOCK_HOOK)
            .WithVerb(HttpMethod.Post)
            .WithJsonProperty <string>(b => b.attachments[0].title_link, "https://hcr.mydomain.net");
        }
Example #3
0
        public async Task NotifyException_Fallback_IncludesMessage(Exception dummy)
        {
            var settings = _fixture.Build <ApplicationSettings>()
                           .WithAutoProperties()
                           .With(f => f.SlackWebhook, MOCK_HOOK)
                           .With(f => f.Nondestructive, false)
                           .Create();

            var _sut = new SlackResultNotifier(settings);

            await _sut.NotifyUnhandledException(dummy);

            _http.ShouldHaveCalled(MOCK_HOOK)
            .WithVerb(HttpMethod.Post)
            .WithJsonProperty <string>(b => b.attachments[0].fallback, $"Unhandled Exception encountered during tag cleanup: {dummy.Message}");
        }
Example #4
0
        public async Task NotifyException_SkipsDryRun(Exception dummy)
        {
            var settings = _fixture.Build <ApplicationSettings>()
                           .WithAutoProperties()
                           .With(f => f.SlackWebhook, MOCK_HOOK)
                           .With(f => f.Nondestructive, false)
                           .Create();

            var _sut = new SlackResultNotifier(settings);

            await _sut.NotifyUnhandledException(dummy);

            _http.ShouldHaveCalled(MOCK_HOOK)
            .WithVerb(HttpMethod.Post)
            .WithJsonPropertyMatching(b => b.attachments[0].fallback, "^Unhandled Exception encountered during tag cleanup.*")
            .WithJsonPropertyMatching(b => b.attachments[0].title, "^Unhandled Exception encountered during tag cleanup.*");
        }