Beispiel #1
0
        public void Match_PatternExpressionsInCalls(string patternData, params int[] matchMethodNumbers)
        {
            var     processor   = new DslProcessor();
            var     patternNode = (PatternNode)processor.Deserialize(patternData, LanguageExt.AllPatternLanguages);
            Pattern pattern     = new Pattern
            {
                Data      = patternNode,
                DebugInfo = patternData
            };

            patternsRep.Add(patternsConverter.ConvertBack(new List <Pattern>()
            {
                pattern
            }));
            WorkflowResult workflowResult = workflow.Process();

            MatchingResultDto[] matchingResults = workflowResult.MatchingResults.ToDto(workflow.SourceCodeRepository);
            patternsRep.Clear();

            Assert.AreEqual(matchMethodNumbers.Contains(0) ? 1 : 0, matchingResults.Count(r => r.MatchedCode.StartsWith("test_call_0")));
            Assert.AreEqual(matchMethodNumbers.Contains(1) ? 1 : 0, matchingResults.Count(r => r.MatchedCode.StartsWith("test_call_1")));
            Assert.AreEqual(matchMethodNumbers.Contains(2) ? 1 : 0, matchingResults.Count(r => r.MatchedCode.StartsWith("test_call_2")));
            Assert.AreEqual(matchMethodNumbers.Contains(3) ? 1 : 0, matchingResults.Count(r => r.MatchedCode.StartsWith("test_call_3")));
            Assert.AreEqual(matchMethodNumbers.Contains(4) ? 1 : 0, matchingResults.Count(r => r.MatchedCode.StartsWith("test_call_4")));
        }
Beispiel #2
0
        //[TestCase("#(#*, <[~e]>, #*)", new[] { 0, 1, 3 })]
        public void Match_PatternExpressionsInCalls(string patternData, params int[] matchMethodNumbers)
        {
            var         processor   = new DslProcessor();
            PatternRoot patternNode = processor.Deserialize(new TextFile(patternData)
            {
                PatternKey = patternData
            });

            patternNode.DebugInfo = patternData;
            patternsRepository.Add(patternsConverter.ConvertBack(new List <PatternRoot> {
                patternNode
            }));
            var logger   = new TestLogger();
            var workflow = new Workflow(sourceRep, patternsRepository)
            {
                Logger = logger
            };

            workflow.Process();
            IEnumerable <MatchResultDto> matchResults = logger.Matches.ToDto();

            patternsRepository.Clear();

            Assert.AreEqual(matchMethodNumbers.Contains(0) ? 1 : 0, matchResults.Count(r => r.MatchedCode.StartsWith("test_call_0")));
            Assert.AreEqual(matchMethodNumbers.Contains(1) ? 1 : 0, matchResults.Count(r => r.MatchedCode.StartsWith("test_call_1")));
            Assert.AreEqual(matchMethodNumbers.Contains(2) ? 1 : 0, matchResults.Count(r => r.MatchedCode.StartsWith("test_call_2")));
            Assert.AreEqual(matchMethodNumbers.Contains(3) ? 1 : 0, matchResults.Count(r => r.MatchedCode.StartsWith("test_call_3")));
            Assert.AreEqual(matchMethodNumbers.Contains(4) ? 1 : 0, matchResults.Count(r => r.MatchedCode.StartsWith("test_call_4")));
        }
        //[TestCase("#(#*, <[~e]>, #*)", new[] { 0, 1, 3 })]
        public void Match_PatternExpressionsInCalls(string patternData, params int[] matchMethodNumbers)
        {
            var         processor   = new DslProcessor();
            PatternRoot patternNode = processor.Deserialize(new CodeFile(patternData)
            {
                IsPattern = true
            });

            patternNode.DebugInfo = patternData;
            patternsRepository.Add(patternsConverter.ConvertBack(new List <PatternRoot>()
            {
                patternNode
            }));
            WorkflowResult workflowResult             = workflow.Process();
            IEnumerable <MatchResultDto> matchResults = workflowResult.MatchResults.ToDto();

            patternsRepository.Clear();

            Assert.AreEqual(matchMethodNumbers.Contains(0) ? 1 : 0, matchResults.Count(r => r.MatchedCode.StartsWith("test_call_0")));
            Assert.AreEqual(matchMethodNumbers.Contains(1) ? 1 : 0, matchResults.Count(r => r.MatchedCode.StartsWith("test_call_1")));
            Assert.AreEqual(matchMethodNumbers.Contains(2) ? 1 : 0, matchResults.Count(r => r.MatchedCode.StartsWith("test_call_2")));
            Assert.AreEqual(matchMethodNumbers.Contains(3) ? 1 : 0, matchResults.Count(r => r.MatchedCode.StartsWith("test_call_3")));
            Assert.AreEqual(matchMethodNumbers.Contains(4) ? 1 : 0, matchResults.Count(r => r.MatchedCode.StartsWith("test_call_4")));
        }