Exemplo n.º 1
0
        public void DefaultSettings_ShouldBeCorrect()
        {
            var slackTarget = new TestableSlackTarget();

            slackTarget.Compact.Should().Be(false);
            slackTarget.WebHookUrl.Should().Be(null);
        }
Exemplo n.º 2
0
        public void CustomSettings_ShouldBeCorrect()
        {
            const string channel    = "#log-${level}";
            const bool   compact    = true;
            const string icon       = ":ghost:";
            const string username   = "******";
            const string webHookUrl = "http://slack.is.awesome.com";

            var slackTarget = new TestableSlackTarget
            {
                Channel    = channel,
                Compact    = compact,
                Icon       = icon,
                Username   = username,
                WebHookUrl = webHookUrl
            };

            var logEvent = new LogEventInfo {
                Level = LogLevel.Info, Message = "This is a ${level} message"
            };

            slackTarget.Channel.Render(logEvent).Should().Be("#log-Info");
            slackTarget.Username.Render(logEvent).Should().Be("NLog.Slack-Info");
            slackTarget.Compact.Should().Be(compact);
            slackTarget.Icon.Should().Be(icon);
            slackTarget.WebHookUrl.Should().Be(webHookUrl);
        }
Exemplo n.º 3
0
        public void CustomSettings_ShouldBeCorrect()
        {
            const string channel = "#log-${level}";
            const bool compact = true;
            const string icon = ":ghost:";
            const string username = "******";
            const string webHookUrl = "http://slack.is.awesome.com";

            var slackTarget = new TestableSlackTarget
                {
                    Channel = channel,
                    Compact = compact,
                    Icon = icon,
                    Username = username,
                    WebHookUrl = webHookUrl
                };

            var logEvent = new LogEventInfo { Level = LogLevel.Info, Message = "This is a ${level} message" };

            slackTarget.Channel.Render(logEvent).Should().Be("#log-Info");
            slackTarget.Username.Render(logEvent).Should().Be("NLog.Slack-Info");
            slackTarget.Compact.Should().Be(compact);
            slackTarget.Icon.Should().Be(icon);
            slackTarget.WebHookUrl.Should().Be(webHookUrl);

            
        }
Exemplo n.º 4
0
        public void InitializeTarget_IncorrectWebHookUrl_ShouldThrowException()
        {
            var slackTarget = new TestableSlackTarget
            {
                WebHookUrl = "IM A BIG FAT PHONY"
            };

            slackTarget.Initialize();
        }
Exemplo n.º 5
0
        public void InitializeTarget_IncorrectWebHookUrl_ShouldThrowException()
        {
            var slackTarget = new TestableSlackTarget
                {
                    WebHookUrl = "IM A BIG FAT PHONY"
                };

            slackTarget.Initialize();
        }
Exemplo n.º 6
0
        public void InitializeTarget_IncorrectChannel_ExtraCharWithAt_ShouldThrowException()
        {
            var slackTarget = new TestableSlackTarget
            {
                WebHookUrl = "http://slack.is.awesome.com",
                Channel    = "w@slackbot"
            };

            slackTarget.Initialize();
        }
Exemplo n.º 7
0
        public void InitializeTarget_CorrectChannelWithVariable_TargetShouldInitialize()
        {
            var slackTarget = new TestableSlackTarget
            {
                WebHookUrl = "http://slack.is.awesome.com",
                Channel    = "@slackbot"
            };

            slackTarget.Initialize();
        }
Exemplo n.º 8
0
        public void DefaultSettings_ShouldBeCorrect()
        {
            var slackTarget = new TestableSlackTarget();

            slackTarget.Channel.Should().Be(null);
            slackTarget.Compact.Should().Be(false);
            slackTarget.Icon.Should().Be(null);
            slackTarget.Username.Should().Be(null);
            slackTarget.WebHookUrl.Should().Be(null);
        }
Exemplo n.º 9
0
        public void CustomSettings_ShouldBeCorrect()
        {
            const bool   compact    = true;
            const string webHookUrl = "http://slack.is.awesome.com";

            var slackTarget = new TestableSlackTarget
            {
                Compact    = compact,
                WebHookUrl = webHookUrl
            };

            var logEvent = new LogEventInfo {
                Level = LogLevel.Info, Message = "This is a ${level} message"
            };

            slackTarget.Compact.Should().Be(compact);
            slackTarget.WebHookUrl.Should().Be(webHookUrl);
        }
Exemplo n.º 10
0
        public void CustomSettings_ShouldBeCorrect()
        {
            const string channel    = "#log";
            const bool   compact    = true;
            const string icon       = ":ghost:";
            const string username   = "******";
            const string webHookUrl = "http://slack.is.awesome.com";

            var slackTarget = new TestableSlackTarget
            {
                Channel    = channel,
                Compact    = compact,
                Icon       = icon,
                Username   = username,
                WebHookUrl = webHookUrl
            };

            slackTarget.Channel.Should().Be(channel);
            slackTarget.Compact.Should().Be(compact);
            slackTarget.Icon.Should().Be(icon);
            slackTarget.Username.Should().Be(username);
            slackTarget.WebHookUrl.Should().Be(webHookUrl);
        }
Exemplo n.º 11
0
        public void InitializeTarget_EmptyWebHookUrl_ShouldThrowException()
        {
            var slackTarget = new TestableSlackTarget();

            slackTarget.Initialize();
        }
Exemplo n.º 12
0
        public void InitializeTarget_IncorrectChannel_ExtraCharWithAt_ShouldThrowException()
        {
            var slackTarget = new TestableSlackTarget
            {
                WebHookUrl = "http://slack.is.awesome.com",
                Channel = "w@slackbot"
            };

            slackTarget.Initialize();
        }
Exemplo n.º 13
0
        public void InitializeTarget_EmptyWebHookUrl_ShouldThrowException()
        {
            var slackTarget = new TestableSlackTarget();

            slackTarget.Initialize();
        }
Exemplo n.º 14
0
        public void InitializeTarget_CorrectChannelWithVariable_TargetShouldInitialize()
        {
            var slackTarget = new TestableSlackTarget
            {
                WebHookUrl = "http://slack.is.awesome.com",
                Channel = "@slackbot"
            };

            slackTarget.Initialize();
        }