コード例 #1
0
 public ChangeSignatureDetectorTests()
 {
     sourceBefore = FileUtil.ReadAllText(TestUtil.GetFakeSourceFolder() + "ChangeMethodSignatureBefore.txt");
     sourceAfter = FileUtil.ReadAllText(TestUtil.GetFakeSourceFolder() + "ChangeMethodSignatureAfter.txt");
     detector = RefactoringDetectorFactory.CreateChangeMethodSignatureDetector();
     detector.SetSourceBefore(sourceBefore);
     detector.SetSourceAfter(sourceAfter);
     logger = NLoggerUtil.GetNLogger(typeof (ChangeSignatureDetectorTests));
 }
コード例 #2
0
 public ChangeSignatureDetectorTests()
 {
     sourceBefore = FileUtil.ReadAllText(TestUtil.GetFakeSourceFolder() +
         "ChangeMethodSignatureBefore.txt");
     sourceAfter = FileUtil.ReadAllText(TestUtil.GetFakeSourceFolder() +
         "ChangeMethodSignatureAfter.txt");
     detector = RefactoringDetectorFactory.GetRefactoringDetectorByType
         (RefactoringType.CHANGE_METHOD_SIGNATURE);
     detector.SetSourceBefore(sourceBefore);
     detector.SetSourceAfter(sourceAfter);
     logger = NLoggerUtil.GetNLogger(typeof (ChangeSignatureDetectorTests));
 }
コード例 #3
0
        public InlineMethodRefactoringTests()
        {
            var convertor = new String2IDocumentConverter();
            this.detector = RefactoringDetectorFactory.CreateInlineMethodDetector();
            this.checkersList = ConditionCheckingFactory.GetInlineMethodConditionsList();
            this.codeBefore = FileUtil.ReadAllText(TestUtil.GetFakeSourceFolder() + "InlineMethodBefore.txt");
            this.codeAfter = FileUtil.ReadAllText(TestUtil.GetFakeSourceFolder() + "InlineMethodAfter.txt");
            this.documentBefore = (IDocument)convertor.Convert(codeBefore, null, null, null);
            this.documentAfter = (IDocument)convertor.Convert(codeAfter, null, null, null);

            detector.SetSourceBefore(codeBefore);
            detector.SetSourceAfter(codeAfter);

            this.dummyDetector = RefactoringDetectorFactory.CreateDummyInlineMethodDetector();
            dummyDetector.SetSourceBefore(codeBefore);
            dummyDetector.SetSourceAfter(codeAfter);
        }
コード例 #4
0
        private bool DetectRefactoringByDetector(string before, string after, IExternalRefactoringDetector detector)
        {
            // Set source before and after.
            detector.SetSourceBefore(before);
            detector.SetSourceAfter(after);

            // If a refactoring is detected.
            if (detector.HasRefactoring())
            {
                // Get the detected refactorings, and log them.
                var refactorings = detector.GetRefactorings();
                foreach (var refactoring in refactorings)
                {
                    var path = HandleDetectedRefactoring(before, after, refactoring);
                    refactoringsCount ++;
                    logger.Info("Refactoring detected! Saved at " + path);
                }
                return true;
            }
            return false;
        }