public void Target_BothCrashesAndAnalytics()
        {
            // Arrange
            var testableAppCenterSink = new TestableAppCenterSink(AppCenterTarget.ExceptionsAsCrashesAndEvents);

            using (var logger = new LoggerConfiguration()
                                .WriteTo.Sink(testableAppCenterSink)
                                .CreateLogger())
            {
                // Act
                logger.Information(new Exception("test"), "test");
            }

            // Assert
            Assert.NotNull(testableAppCenterSink.LastAnalyticsProperties);
            Assert.NotNull(testableAppCenterSink.LastCrashProperties);
        }
        public void Crashes_IncludeExceptions(string exceptionMessage)
        {
            // Arrange
            var testableAppCenterSink = new TestableAppCenterSink();

            using (var logger = new LoggerConfiguration()
                                .WriteTo.Sink(testableAppCenterSink)
                                .CreateLogger())
            {
                // Act
                logger.Information(new Exception(exceptionMessage), "test");
            }

            // Assert
            Assert.NotNull(testableAppCenterSink.LastException);
            Assert.Equal(exceptionMessage, testableAppCenterSink.LastException.Message);
        }
        public void LogLevel_PropertiesContainsLevel(LogEventLevel level)
        {
            // Arrange
            var testableAppCenterSink = new TestableAppCenterSink();

            using (var logger = new LoggerConfiguration()
                                .WriteTo.Sink(testableAppCenterSink)
                                .CreateLogger())
            {
                // Act
                logger.Write(level, "test");
            }

            // Assert
            var val = Assert.Contains("level", testableAppCenterSink.LastAnalyticsProperties);

            Assert.Equal(level.ToString(), val);
        }
        public void Crashes_IncludeMessages(string messageSample)
        {
            // Arrange
            var testableAppCenterSink = new TestableAppCenterSink();

            using (var logger = new LoggerConfiguration()
                                .WriteTo.Sink(testableAppCenterSink)
                                .CreateLogger())
            {
                // Act
                logger.Information(new Exception("test"), messageSample);
            }

            // Assert
            var val = Assert.Contains("message", testableAppCenterSink.LastCrashProperties);

            Assert.Equal(messageSample, val);
        }
        public void FormattedMessage_CorrectProperties(string subject)
        {
            // Arrange
            const string logId      = "logSubject";
            const string logMessage = "Successfully logged {logSubject}";

            var testableAppCenterSink = new TestableAppCenterSink();

            using (var logger = new LoggerConfiguration()
                                .WriteTo.Sink(testableAppCenterSink)
                                .CreateLogger())
            {
                // Act
                logger.Information(logMessage, subject);
            }

            // Assert
            var val = Assert.Contains(logId, testableAppCenterSink.LastAnalyticsProperties);

            Assert.Equal(subject, val);
            Assert.Equal(logMessage, testableAppCenterSink.LastMessage);
        }