Esempio n. 1
0
        public void UseMeaningfulName_IgnoreQuickFixWorks()
        {
            const string inputCode =
                @"Sub Ffffff()
End Sub";

            const string expectedCode =
                @"'@Ignore UseMeaningfulName
Sub Ffffff()
End Sub";

            var builder = new MockVbeBuilder();
            var project = builder.ProjectBuilder("VBAProject", ProjectProtection.Unprotected)
                          .AddComponent("MyClass", ComponentType.ClassModule, inputCode)
                          .Build();
            var component = project.Object.VBComponents[0];
            var vbe       = builder.AddProject(project).Build();

            using (var state = MockParser.CreateAndParse(vbe.Object))
            {
                var inspection        = new UseMeaningfulNameInspection(state, UseMeaningfulNameInspectionTests.GetInspectionSettings().Object);
                var inspectionResults = inspection.GetInspectionResults(CancellationToken.None);

                new IgnoreOnceQuickFix(state, new[] { inspection }).Fix(inspectionResults.First());
                Assert.AreEqual(expectedCode, state.GetRewriter(component).GetText());
            }
        }
Esempio n. 2
0
        public void UseMeaningfulName_IgnoreQuickFixWorks()
        {
            const string inputCode =
                @"Sub Ffffff()
End Sub";

            const string expectedCode =
                @"'@Ignore UseMeaningfulName
Sub Ffffff()
End Sub";

            var builder = new MockVbeBuilder();
            var project = builder.ProjectBuilder("VBAProject", ProjectProtection.Unprotected)
                          .AddComponent("MyClass", ComponentType.ClassModule, inputCode)
                          .Build();
            var component = project.Object.VBComponents[0];
            var vbe       = builder.AddProject(project).Build();

            var(state, rewritingManager) = MockParser.CreateAndParseWithRewritingManager(vbe.Object);
            using (state)
            {
                var inspection        = new UseMeaningfulNameInspection(state, UseMeaningfulNameInspectionTests.GetInspectionSettings().Object);
                var inspectionResults = inspection.GetInspectionResults(CancellationToken.None);
                var rewriteSession    = rewritingManager.CheckOutCodePaneSession();

                new IgnoreOnceQuickFix(new AnnotationUpdater(), state, new[] { inspection }).Fix(inspectionResults.First(), rewriteSession);
                var actualCode = rewriteSession.CheckOutModuleRewriter(component.QualifiedModuleName).GetText();

                Assert.AreEqual(expectedCode, actualCode);
            }
        }
        public void UseMeaningfulName_IgnoreQuickFixWorks()
        {
            const string inputCode =
                @"Sub Ffffff()
End Sub";

            const string expectedCode =
                @"'@Ignore UseMeaningfulName
Sub Ffffff()
End Sub";

            var builder = new MockVbeBuilder();
            var project = builder.ProjectBuilder("VBAProject", ProjectProtection.Unprotected)
                          .AddComponent("MyClass", ComponentType.ClassModule, inputCode)
                          .Build();
            var component = project.Object.VBComponents[0];
            var vbe       = builder.AddProject(project).Build();

            var parser = MockParser.Create(vbe.Object);

            parser.Parse(new CancellationTokenSource());
            if (parser.State.Status >= ParserState.Error)
            {
                Assert.Inconclusive("Parser Error");
            }

            var inspection        = new UseMeaningfulNameInspection(parser.State, UseMeaningfulNameInspectionTests.GetInspectionSettings().Object);
            var inspectionResults = inspection.GetInspectionResults();

            new IgnoreOnceQuickFix(parser.State, new[] { inspection }).Fix(inspectionResults.First());
            Assert.AreEqual(expectedCode, parser.State.GetRewriter(component).GetText());
        }