コード例 #1
0
 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());
 }
コード例 #2
0
 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);
 }
コード例 #3
0
 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()));
 }
コード例 #4
0
 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);
 }
コード例 #5
0
 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());
 }
コード例 #6
0
 public void EmptyWebHookUrlThrowsError()
 {
     var client = new MockSlackClient(true);
     var reporter = new WebHookExceptionReporter(client);
     reporter.ReportException(new Exception(), new WebHookOptions(""));
 }
コード例 #7
0
 public void ClientReportsTrue()
 {
     var client = new MockSlackClient(true);
     var reporter = new WebHookExceptionReporter(client);
     Assert.IsTrue(reporter.ReportException(new Exception(), TestHelpers.GetMinimalOptions()));
 }
コード例 #8
0
        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);
        }
コード例 #9
0
 public void NullOptionsThrowsError()
 {
     var client = new MockSlackClient(true);
     var reporter = new WebHookExceptionReporter(client);
     reporter.ReportException(new Exception(), null);
 }