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```"); }
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"); }
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}"); }
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.*"); }