Example #1
0
        public void TestDisabledManager_AddLogToDisabledManager_ShouldntEnqueueMessage()
        {
            var logManager = new BacktraceLogManager(0);

            logManager.Enqueue("fake message", string.Empty, LogType.Log);
            Assert.AreEqual(0, logManager.Size);
        }
Example #2
0
        public void TestMessageQueue_AddLogToEnabledManager_ShouldEnqueueMessage()
        {
            uint expectedNumberOfMessages = 1;
            var  logManager = new BacktraceLogManager(expectedNumberOfMessages);

            logManager.Enqueue("fake message", string.Empty, LogType.Log);
            Assert.AreEqual(expectedNumberOfMessages, logManager.Size);
        }
Example #3
0
 /// <summary>
 /// Handle Untiy unhandled exceptions
 /// </summary>
 private void CaptureUnityMessages()
 {
     _backtraceLogManager = new BacktraceLogManager(Configuration.NumberOfLogs);
     if (Configuration.HandleUnhandledExceptions || Configuration.NumberOfLogs != 0)
     {
         Application.logMessageReceived += HandleUnityMessage;
     }
 }
Example #4
0
        public void TestLogManagerSourceCodeGeneration_ShouldReturnStringSourceCode_CorrectSourceCodeGenerationFromEmptyLog()
        {
            var type = LogType.Log;
            var backtraceUnityLogManager = new BacktraceLogManager(1);

            backtraceUnityLogManager.Enqueue(string.Empty, string.Empty, type);
            var sourceCodeText = backtraceUnityLogManager.ToSourceCode();

            Assert.IsNotEmpty(sourceCodeText);
        }
Example #5
0
        public void TestLogManagerLimit_AddExceptionReportsThatMatchLimitCriteria_AllMessagesShouldBeInLogManager(int numberOfLogs)
        {
            var report = new BacktraceReport(new Exception(string.Empty));
            var backtraceUnityLogManager = new BacktraceLogManager((uint)numberOfLogs);

            for (int i = 0; i < numberOfLogs; i++)
            {
                backtraceUnityLogManager.Enqueue(report);
            }
            Assert.AreEqual(backtraceUnityLogManager.Size, numberOfLogs);
        }
Example #6
0
        /// <summary>
        /// Handle Unity unhandled exceptions
        /// </summary>
        private void CaptureUnityMessages()
        {
            _backtraceLogManager = new BacktraceLogManager(Configuration.NumberOfLogs);
            if (Configuration.HandleUnhandledExceptions || Configuration.NumberOfLogs != 0)
            {
                Application.logMessageReceived += HandleUnityMessage;
#if UNITY_ANDROID || UNITY_IOS
                Application.lowMemory += HandleLowMemory;
#endif
            }
        }
Example #7
0
        public void TestLogManagerLimit_AddMessagesThatMatchLimitCriteria_AllMessagesShouldBeInLogManager(int numberOfLogs)
        {
            var message    = "fake message";
            var stackTrace = string.Empty;
            var type       = LogType.Log;
            var backtraceUnityLogManager = new BacktraceLogManager((uint)numberOfLogs);

            for (int i = 0; i < numberOfLogs; i++)
            {
                backtraceUnityLogManager.Enqueue(message, stackTrace, type);
            }
            Assert.AreEqual(backtraceUnityLogManager.Size, numberOfLogs);
        }
Example #8
0
        public void TestMessageQueue_AddMultipleLosgToEnabledManager_ShouldEnqueueLimitMessage()
        {
            uint expectedNumberOfMessages = 1;
            var  logManager = new BacktraceLogManager(expectedNumberOfMessages);

            logManager.Enqueue("deleted message", string.Empty, LogType.Log);
            var enqueuedMessage = "enqueued message";

            logManager.Enqueue(enqueuedMessage, string.Empty, LogType.Log);

            Assert.AreEqual(expectedNumberOfMessages, logManager.Size);
            Assert.AreEqual(enqueuedMessage, logManager.LogQueue.First().Message);
        }
Example #9
0
        public void TestLogManagerSourceCodeGeneration_ShouldReturnStringSourceCode_CorrectSourceCodeGenerationWithStackTraceForException()
        {
            var message    = "Message";
            var stackTrace = "stack trace";
            var type       = LogType.Exception;
            var backtraceUnityLogManager = new BacktraceLogManager(1);

            backtraceUnityLogManager.Enqueue(message, stackTrace, type);
            var sourceCodeText = backtraceUnityLogManager.ToSourceCode();

            Assert.IsNotEmpty(sourceCodeText);
            Assert.IsTrue(sourceCodeText.Contains(message));
            Assert.IsTrue(sourceCodeText.Contains(stackTrace));
        }
Example #10
0
        public void TestMessageQueue_AddMultipleLosgToEnabledManager_ShouldEnqueueLimitMessage()
        {
            uint expectedNumberOfMessages = 1;
            var  logManager = new BacktraceLogManager(expectedNumberOfMessages);

            logManager.Enqueue("deleted message", string.Empty, LogType.Log);
            var enqueuedMessage = "enqueued message";

            logManager.Enqueue(enqueuedMessage, string.Empty, LogType.Log);

            Assert.AreEqual(expectedNumberOfMessages, logManager.Size);
            // validate if log ends with enqueueMessage to validate if message is there,
            // without checking other message content (date, log type etc..)
            Assert.IsTrue(logManager.LogQueue.First().EndsWith(enqueuedMessage));
        }
Example #11
0
        public void TestLogManagerSourceCodeGeneration_ShouldReturnStringSourceCodeForEmptyValues_CorrectSourceCodeGenerationWithStackTraceForException()
        {
            var message    = string.Empty;
            var stackTrace = string.Empty;
            var type       = LogType.Log;
            var backtraceUnityLogManager = new BacktraceLogManager(1);

            backtraceUnityLogManager.Enqueue(message, stackTrace, type);
            string sourceCodeText = string.Empty;

            Assert.DoesNotThrow(() =>
            {
                sourceCodeText = backtraceUnityLogManager.ToSourceCode();
            });

            Assert.IsNotEmpty(sourceCodeText);
        }
Example #12
0
        public void TestLogManagerInitialization_LimitNotEqualToZero_ShouldBeEnabled()
        {
            var logManager = new BacktraceLogManager(1);

            Assert.IsFalse(logManager.Disabled);
        }
Example #13
0
        public void TestLogManagerInitialization_LimitEqualToZero_ShouldBeDisabled()
        {
            var logManager = new BacktraceLogManager(0);

            Assert.IsTrue(logManager.Disabled);
        }