Beispiel #1
0
        public void ObsoleteErrorSyntax_DoesNotReturnResult_ErrorInStringLiteral()
        {
            const string inputCode =
                @"Sub Foo()
    Dim bar As String
    bar = ""Error 91"" ' test
End Sub";
            var vbe = MockVbeBuilder.BuildFromSingleStandardModule(inputCode, out _);

            using (var state = MockParser.CreateAndParse(vbe.Object))
            {
                var inspection        = new ObsoleteErrorSyntaxInspection(state);
                var inspector         = InspectionsHelper.GetInspector(inspection);
                var inspectionResults = inspector.FindIssuesAsync(state, CancellationToken.None).Result;

                Assert.AreEqual(0, inspectionResults.Count());
            }
        }
        public void ObsoleteErrorSyntax_Ignored_DoesNotReturnResult()
        {
            const string inputCode =
                @"Sub Foo()
    '@Ignore ObsoleteErrorSyntax
    Error 91
End Sub";
            var vbe = MockVbeBuilder.BuildFromSingleStandardModule(inputCode, out _);

            using (var state = MockParser.CreateAndParse(vbe.Object))
            {
                var inspection        = new ObsoleteErrorSyntaxInspection(state);
                var inspector         = InspectionsHelper.GetInspector(inspection);
                var inspectionResults = inspector.FindIssuesAsync(state, CancellationToken.None).Result;

                Assert.IsFalse(inspectionResults.Any());
            }
        }
        public void ObsoleteErrorSyntax_ReturnsMultipleResults()
        {
            const string inputCode =
                @"Sub Foo()
    Error 91
    Error 91
End Sub";
            var vbe = MockVbeBuilder.BuildFromSingleStandardModule(inputCode, out _);

            using (var state = MockParser.CreateAndParse(vbe.Object))
            {
                var inspection        = new ObsoleteErrorSyntaxInspection(state);
                var inspector         = InspectionsHelper.GetInspector(inspection);
                var inspectionResults = inspector.FindIssuesAsync(state, CancellationToken.None).Result;

                Assert.AreEqual(2, inspectionResults.Count());
            }
        }
        public void ObsoleteCommentSyntax_QuickFixWorks_UpdateComment_LineHasCode()
        {
            const string inputCode =
                @"Sub Foo()
    Dim foo: Error 91
End Sub";

            const string expectedCode =
                @"Sub Foo()
    Dim foo: Err.Raise 91
End Sub";

            var vbe   = MockVbeBuilder.BuildFromSingleStandardModule(inputCode, out var component);
            var state = MockParser.CreateAndParse(vbe.Object);

            var inspection        = new ObsoleteErrorSyntaxInspection(state);
            var inspector         = InspectionsHelper.GetInspector(inspection);
            var inspectionResults = inspector.FindIssuesAsync(state, CancellationToken.None).Result;

            new ReplaceObsoleteErrorStatementQuickFix(state).Fix(inspectionResults.First());
            Assert.AreEqual(expectedCode, state.GetRewriter(component).GetText());
        }
        public void ObsoleteErrorSyntax_IgnoreQuickFixWorks()
        {
            const string inputCode =
                @"Sub Foo()
    Error 91
End Sub";

            const string expectedCode =
                @"Sub Foo()
'@Ignore ObsoleteErrorSyntax
    Error 91
End Sub";

            var vbe   = MockVbeBuilder.BuildFromSingleStandardModule(inputCode, out var component);
            var state = MockParser.CreateAndParse(vbe.Object);

            var inspection        = new ObsoleteErrorSyntaxInspection(state);
            var inspector         = InspectionsHelper.GetInspector(inspection);
            var inspectionResults = inspector.FindIssuesAsync(state, CancellationToken.None).Result;

            new IgnoreOnceQuickFix(state, new[] { inspection }).Fix(inspectionResults.First());
            Assert.AreEqual(expectedCode, state.GetRewriter(component).GetText());
        }
        public void InspectionName()
        {
            var inspection = new ObsoleteErrorSyntaxInspection(null);

            Assert.AreEqual(nameof(ObsoleteErrorSyntaxInspection), inspection.Name);
        }
Beispiel #7
0
        public void InspectionType()
        {
            var inspection = new ObsoleteErrorSyntaxInspection(null);

            Assert.AreEqual(CodeInspectionType.LanguageOpportunities, inspection.InspectionType);
        }