Beispiel #1
0
        public void Dispose_100VariousLogsRaised_NoExceptionsThrown()
        {
            // Arrange
            var logger = new SqlLogger(new AzureLoggerSettingsConfiguration(), new NullCorrelationIdHelper());

            for (int i = 0; i < 100; i++)
            {
                switch (i % 5)
                {
                case 0:
                    logger.LogDebug(string.Format("Test run index {0}", i), metaData: new Dictionary <string, object> {
                        { "accountId", i }
                    });
                    break;

                case 1:
                    logger.LogError(string.Format("Test run index {0}", i), metaData: new Dictionary <string, object> {
                        { "teamId", i }
                    });
                    break;

                case 2:
                    logger.LogFatalError(string.Format("Test run index {0}", i), metaData: new Dictionary <string, object> {
                        { "userId", i }
                    });
                    break;

                case 3:
                    logger.LogInfo(string.Format("Test run index {0}", i), metaData: new Dictionary <string, object> {
                        { "companyId", i }
                    });
                    break;

                case 4:
                    logger.LogError(string.Format("Test run index {0}", i), metaData: new Dictionary <string, object> {
                        { "jobId", i }
                    });
                    break;
                }
            }

            // Act
            logger.Dispose();

            // Assert
            // No exception thrown
        }
Beispiel #2
0
        public void PoolingThread_100LogsRaisedAndAPauseThenAnotherLog_PoolingThreadShutsDownAndStartsUpAgain()
        {
            // Arrange
            var logger = new SqlLogger(new TestApplicationSettings {
                EnableThreadedLogging = true, EnableDebug = true
            }, new NullCorrelationIdHelper());

            logger.LogDebug(string.Format("Test run index {0}", 0));
            logger.LogDebug(string.Format("Test run index {0}", 1));
            Thread.Sleep(5000);

            for (int i = 2; i < 100; i++)
            {
                logger.LogDebug(string.Format("Test run index {0}", i));
            }
            Thread.Sleep(5000);

            // Act
            logger.LogDebug(string.Format("Test run index {0}", 100));

            // Assert
            // No exception thrown and disposing
            logger.Dispose();
        }