Exemple #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");
        }
Exemple #2
0
        public void SendLogMessageToLoggly___Should_throw_InvalidOperationException___When_Initialize_has_not_been_called()
        {
            // Arrange, Act
            var ex = Record.Exception(() => LogglySender.SendLogMessageToLoggly(A.Dummy <string>(), A.Dummy <string>(), A.Dummy <string>(), A.Dummy <Severity>(), DateTime.UtcNow, A.Dummy <string>(), A.Dummy <string>()));

            // Assert
            ex.Should().BeOfType <InvalidOperationException>();
            ex.Message.Should().Be("Initialize has not yet been called.");
        }
Exemple #3
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");
        }
Exemple #4
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");
        }
Exemple #5
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");
        }
Exemple #6
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");
        }
Exemple #7
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);
        }