public void AttachmentTextContainsExceptionMessage() { const string message = "This is a test exception."; var client = new MockSlackClient(x => Assert.IsTrue(x.Attachments[0].Text.Contains(message))); var reporter = new WebHookExceptionReporter(client); reporter.ReportException(new Exception(message), TestHelpers.GetMinimalOptions()); }
public void AttachmentTextIsCustomFormat() { const string format = "This is the custom format for the attachment."; var client = new MockSlackClient(x => Assert.AreEqual(format, x.Attachments[0].Text)); var reporter = new WebHookExceptionReporter(client); var options = TestHelpers.GetMinimalOptions(); options.ExceptionTextFormat = format; reporter.ReportException(new Exception(), options); }
public void MessageDefaultsAreCorrect() { var client = new MockSlackClient(x => { Assert.IsNull(x.Channel); Assert.IsNull(x.Username); Assert.AreEqual(WebHookExceptionReporter.DEFAULT_TEXT, x.Text); Assert.AreEqual(WebHookExceptionReporter.DEFAULT_COLOR, x.Attachments[0].Color); Assert.AreEqual(Webhooks.Emoji.HeavyExclamationMark, x.IconEmoji); Assert.AreEqual("text", x.Attachments[0].MrkdwnIn.First()); }); var reporter = new WebHookExceptionReporter(client); Assert.IsTrue(reporter.ReportException(new Exception(), TestHelpers.GetMinimalOptions())); }
public void NullCustomExceptionFormatIsDefault() { var client = new MockSlackClient(x => Assert.IsFalse(string.IsNullOrWhiteSpace(x.Attachments[0].Text))); var reporter = new WebHookExceptionReporter(client); var options = TestHelpers.GetMinimalOptions(); options.ExceptionTextFormat = null; reporter.ReportException(new Exception(), options); }
public void MessageHasAttachment() { var client = new MockSlackClient(x => Assert.IsTrue(x.Attachments.Count > 0)); var reporter = new WebHookExceptionReporter(client); reporter.ReportException(new Exception(), TestHelpers.GetMinimalOptions()); }
public void EmptyWebHookUrlThrowsError() { var client = new MockSlackClient(true); var reporter = new WebHookExceptionReporter(client); reporter.ReportException(new Exception(), new WebHookOptions("")); }
public void ClientReportsTrue() { var client = new MockSlackClient(true); var reporter = new WebHookExceptionReporter(client); Assert.IsTrue(reporter.ReportException(new Exception(), TestHelpers.GetMinimalOptions())); }
public void OptionValuesAreInMessage() { const string channelName = "#testChannel"; const string userName = "******"; const string emoji = "emoji"; const string text = "message text"; const string attColor = "attachment color"; const string attTitle = "attachment title"; const string attTitleLink = "attachment title link"; var client = new MockSlackClient(x => { Assert.AreEqual(channelName, x.Channel); Assert.AreEqual(userName, x.Username); Assert.AreEqual(emoji, x.IconEmoji); Assert.AreEqual(text, x.Text); Assert.AreEqual(attColor, x.Attachments[0].Color); Assert.AreEqual(attTitle, x.Attachments[0].Title); Assert.AreEqual(attTitleLink, x.Attachments[0].TitleLink); }); var reporter = new WebHookExceptionReporter(client); var options = TestHelpers.GetMinimalOptions(); options.ChannelName = channelName; options.UserName = userName; options.IconEmoji = emoji; options.Text = text; options.AttachmentColor = attColor; options.AttachmentTitle = attTitle; options.AttachmentTitleLink = attTitleLink; reporter.ReportException(new Exception(), options); }
public void NullOptionsThrowsError() { var client = new MockSlackClient(true); var reporter = new WebHookExceptionReporter(client); reporter.ReportException(new Exception(), null); }