public void TestNewParsingMethod()
        {
            var sourceFileHasher = new SourceFileHasher();
            var tokenDictionary  = new Dictionary <int, List <SourceFileHasher.NewSourceEntry> >();

            foreach (var file in Directory.GetFiles(@"C:\CONGEN\cnt\agent-library\", "*.cs", SearchOption.AllDirectories))
            {
                sourceFileHasher.ProcessFile2(file, tokenDictionary);
            }

            //var logLines = new string[]{ "AgentHostProcess is started",
            //    "Service configured on port 8085 of channel http.Server object created",
            //    "Execution steps cache initialized, total 22 item(s)" };

            var logLines = File.ReadAllLines(TestContext.CurrentContext.TestDirectory + "\\out2.txt");

            var tokenizer = new WhiteSpaceLogTokenizer();

            foreach (var logLine in logLines.Where(_ => !string.IsNullOrWhiteSpace(_)))
            {
                foreach (var newSourceEntry in sourceFileHasher.SearchNew(tokenizer.TokenizeLine(logLine).ToList(), tokenDictionary))
                {
                    PrintSrcFile(sourceFileHasher.FilesDictionary[newSourceEntry.FileHash], newSourceEntry.Line, logLine);
                }
            }
        }
        public void CorrelateLogsTest()
        {
            var logLines = new string[] { "AgentHostProcess is started",
                                          "Service configured on port 8085 of channel http.Server object created",
                                          "Execution steps cache initialized, total 22 item(s)" };

            //var logLines = File.ReadAllLines(TestContext.CurrentContext.TestDirectory +"\\out1.txt");

            var tokenizer = new WhiteSpaceLogTokenizer();

            var restoreFileHasher = new SourceFileHasher();

            restoreFileHasher.RestoreFromFile(tempSavePath);

            foreach (var logLine in logLines)
            {
                var tokenizedLine = tokenizer.TokenizeLine(logLine);

                var sourceEntries = restoreFileHasher.SearchSequence(tokenizedLine.ToList(), restoreFileHasher.FilesToTokens);

                foreach (var sourceEntry in sourceEntries)
                {
                    PrintSrcFile(restoreFileHasher.FilesDictionary[sourceEntry.FileHash], sourceEntry.LineNumber, logLine);
                }
            }
        }
 public void TestArrInArr(int[] x, int[] y, int idx)
 {
     Assert.AreEqual(idx, SourceFileHasher.FindArrayIndex(x, y));
     if (idx != -1)
     {
         Assert.IsTrue(x[0] == y[idx]);
     }
 }
        public void FileTokenizationTest()
        {
            var sourceFileHasher = new SourceFileHasher();
            var stopwatch        = Stopwatch.StartNew();

            sourceFileHasher.ProcessFile(@"D:\CONGEN\cnt\agent-library\AgentSkills\AgentSkills\InformationAgent.FetchnExtract\fetchnextract.cs");
            stopwatch.Stop();
            Console.WriteLine(stopwatch.Elapsed);
            Assert.Pass();
        }
        public void AlTokenizationTest()
        {
            var sourceFileHasher = new SourceFileHasher();
            var stopwatch        = Stopwatch.StartNew();

            foreach (var file in Directory.GetFiles(@"D:\CONGEN\cnt\agent-library\", "*.cs", SearchOption.AllDirectories))
            {
                sourceFileHasher.ProcessFile(file);
            }

            sourceFileHasher.SaveToFile(tempSavePath);

            stopwatch.Stop();

            var restoreFileHasher = new SourceFileHasher();

            restoreFileHasher.RestoreFromFile(tempSavePath);

            Assert.AreEqual(restoreFileHasher.Entries, sourceFileHasher.Entries);
            Assert.AreEqual(restoreFileHasher.FilesDictionary, sourceFileHasher.FilesDictionary);

            Console.WriteLine(stopwatch.Elapsed);
            Assert.Pass();
        }
 public void RemoveQuotesTest()
 {
     Console.WriteLine(SourceFileHasher.RemoveQuotes("\"\""));
 }