aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.UnitTesting/Logging/Parsing_TST.cs
blob: 8cc87e70065c2193e5d0cddb19389867d8138294 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Tango.Integration.Logging;
using Tango.Logging;

namespace Tango.UnitTesting.Logging
{
    [TestClass]
    [TestCategory("Logging")]
    public class Parsing_TST
    {
        [TestMethod]
        public void Parse_Application_Logs()
        {
            ApplicationLogFileParser parser = new ApplicationLogFileParser();
            var logFiles = parser.GetLogFiles();
            var logFile = logFiles.OrderByDescending(x => x.DateTime).First();
            var logs = parser.Parse(logFile);
        }

        [TestMethod]
        public void Parse_Embedded_Logs()
        {
            EmbeddedLogFileParser parser = new EmbeddedLogFileParser();
            var logFiles = parser.GetLogFiles();
            var logFile = logFiles.OrderByDescending(x => x.DateTime).First();
            var logs = parser.Parse(logFile);
        }

        [TestMethod]
        public void Parse_Multi_Part_Log_Files()
        {
            var manager = LogManager.Default;
            var fileLogger = new FileLogger();
            var folder = FileLogger.DefaultLogsFolder;
            fileLogger.EnableMaxFileSizeLimit = true;
            fileLogger.MaxFileSizeLimit = 10000;
            LogManager.Default.RegisterLogger(fileLogger);
            for (int i = 0; i < 100; i++)
            {
                manager.Log($"This is a test {i}");
                Thread.Sleep(100);
            }
            Thread.Sleep(1000);
            ApplicationLogFileParser parser = new ApplicationLogFileParser();
            var logFiles = parser.GetLogFiles();
            var logFile = logFiles.OrderByDescending(x => x.DateTime).First();
            var logs = parser.Parse(logFile);
        }
    }
}
span class="p">} } void ITextViewConnect.RemoveFromTextView(TextView textView) { if (wasAutoAddedToTextView && this.TextView == textView) { this.TextView = null; Debug.Assert(!wasAutoAddedToTextView); // setting this.TextView should have unset this flag } } TextDocument document; /// <summary> /// Gets the document associated with the margin. /// </summary> public TextDocument Document { get { return document; } } /// <summary> /// Called when the <see cref="TextView"/> is changing. /// </summary> protected virtual void OnTextViewChanged(TextView oldTextView, TextView newTextView) { if (oldTextView != null) { oldTextView.DocumentChanged -= TextViewDocumentChanged; } if (newTextView != null) { newTextView.DocumentChanged += TextViewDocumentChanged; } TextViewDocumentChanged(null, null); } void TextViewDocumentChanged(object sender, EventArgs e) { OnDocumentChanged(document, TextView != null ? TextView.Document : null); } /// <summary> /// Called when the <see cref="Document"/> is changing. /// </summary> protected virtual void OnDocumentChanged(TextDocument oldDocument, TextDocument newDocument) { document = newDocument; } } }