Beispiel #1
0
        public void Initialize___Should_throw_ArgumentNullException___When_parameter_logglySettings_is_null()
        {
            // Arrange, Act
            var ex = Record.Exception(() => LogglySender.Initialize(null));

            // Assert
            ex.Should().BeOfType <ArgumentNullException>();
            ex.Message.Should().Contain("logglySettings");
        }
Beispiel #2
0
        public void Initialize___Should_throw_ArgumentException___When_parameter_logglySettings_LogglyPrivateEnterpriseNumber_is_null()
        {
            // Arrange
            var settings = BuildLogglySettings();

            settings.LogglyPrivateEnterpriseNumber = null;

            // Act
            var ex = Record.Exception(() => LogglySender.Initialize(settings));

            // Assert
            ex.Should().BeOfType <ArgumentException>();
            ex.Message.Should().Contain("'logglySettings.LogglyPrivateEnterpriseNumber' is null or white space");
        }
Beispiel #3
0
        public void Initialize___Should_throw_ArgumentException___When_parameter_logglySettings_LogglyServerCertificatePemEncoded_is_null()
        {
            // Arrange
            var settings = BuildLogglySettings();

            settings.LogglyServerCertificatePemEncoded = null;

            // Act
            var ex = Record.Exception(() => LogglySender.Initialize(settings));

            // Assert
            ex.Should().BeOfType <ArgumentException>();
            ex.Message.Should().Contain("LogglyServerCertificatePemEncoded");
        }
Beispiel #4
0
        public void Initialize___Should_throw_ArgumentException___When_parameter_logglySettings_SecurePort_is_default_value()
        {
            // Arrange
            var settings = BuildLogglySettings();

            settings.SecurePort = default(int);

            // Act
            var ex = Record.Exception(() => LogglySender.Initialize(settings));

            // Assert
            ex.Should().BeOfType <ArgumentException>();
            ex.Message.Should().Be("'SecurePort' has not be set");
        }
Beispiel #5
0
        public void Initialize___Should_throw_ArgumentException___When_parameter_logglySettings_CustomerToken_is_white_space()
        {
            // Arrange
            var settings = BuildLogglySettings();

            settings.CustomerToken = "  \r\n  ";

            // Act
            var ex = Record.Exception(() => LogglySender.Initialize(settings));

            // Assert
            ex.Should().BeOfType <ArgumentException>();
            ex.Message.Should().Contain("CustomerToken");
            ex.Message.Should().Contain("white space");
        }
Beispiel #6
0
        public void SendLogMessageToLoggly()
        {
            // Arrange
            var settings = BuildLogglySettings();

            LogglySender.Initialize(settings);

            var machineName     = "MachineName";
            var applicationName = "ApplicationName";
            var processId       = "ProcessId";
            var severity        = Severity.Notice;
            var timestamp       = DateTime.UtcNow;
            var messagePayload  = "{ \"property1\": true, \"property2\": \"some text\" }";
            var messageType     = "MessageType";
            var tags            = new[] { new LogglyTag("tag1"), new LogglyTag("tag2") };

            // Act, Assert
            LogglySender.SendLogMessageToLoggly(machineName, applicationName, processId, severity, timestamp, messagePayload, messageType, tags);
        }