示例#1
0
        public async Task ServiceReturnsSyntaxErrors()
        {
            // Send the 'didOpen' event
            await this.SendOpenFileEvent("TestFiles\\SimpleSyntaxError.ps1", false);

            // Wait for the diagnostic event
            PublishDiagnosticsNotification diagnostics = this.WaitForEvent(PublishDiagnosticsNotification.Type);

            // Was there a syntax error?
            Assert.NotEqual(0, diagnostics.Diagnostics.Length);
            Assert.False(
                string.IsNullOrEmpty(diagnostics.Diagnostics[0].Message));
        }
        public async Task ServiceReturnsNoErrorsForUsingRelativeModulePaths()
        {
            // Send the 'didOpen' event
            await this.SendOpenFileEvent("TestFiles\\Module.psm1", false);

            // Wait for the diagnostic event
            PublishDiagnosticsNotification diagnostics =
                await this.WaitForEvent(
                    PublishDiagnosticsNotification.Type);

            // Was there a syntax error?
            Assert.Equal(0, diagnostics.Diagnostics.Length);
        }
示例#3
0
        public async Task ServiceReturnsNoErrorsForUsingRelativeModulePaths()
        {
            // Send the 'didOpen' event
            await this.SendOpenFileEvent(TestUtilities.NormalizePath("TestFiles/Module.psm1"), false);

            // Wait for the diagnostic event
            PublishDiagnosticsNotification diagnostics =
                await this.WaitForEvent(
                    PublishDiagnosticsNotification.Type);

            // Was there a syntax error?
            Assert.Empty(diagnostics.Diagnostics);
        }
        public async Task ServiceReturnsSemanticMarkers()
        {
            // Send the 'didOpen' event
            await this.SendOpenFileEvent("TestFiles\\SimpleSemanticError.ps1", false);

            // Wait for the diagnostic event
            PublishDiagnosticsNotification diagnostics =
                await this.WaitForEvent(
                    PublishDiagnosticsNotification.Type);

            // Was there a semantic error?
            Assert.NotEqual(0, diagnostics.Diagnostics.Length);
            Assert.Contains("unapproved", diagnostics.Diagnostics[0].Message);
        }
示例#5
0
        public async Task ServiceReturnsSemanticMarkers()
        {
            // Send the 'didOpen' event
            await this.SendOpenFileEvent(TestUtilities.NormalizePath("TestFiles/SimpleSemanticError.ps1"), false);

            // Wait for the diagnostic event
            PublishDiagnosticsNotification diagnostics =
                await this.WaitForEvent(
                    PublishDiagnosticsNotification.Type);

            // Was there a semantic error?
            Assert.NotEmpty(diagnostics.Diagnostics);
            Assert.Contains("unapproved", diagnostics.Diagnostics[0].Message);
        }
示例#6
0
        private Task HandlePublishDiagnosticsEvent(
            PublishDiagnosticsNotification diagnostics,
            EventContext eventContext)
        {
            string normalizedPath = diagnostics.Uri.ToLower();

            this.cachedDiagnostics[normalizedPath] =
                diagnostics.Diagnostics
                .Select(GetMarkerFromDiagnostic)
                .ToArray();

            this.OnDiagnosticsReceived(normalizedPath);

            return(Task.FromResult(true));
        }
示例#7
0
        public async Task ServiceReturnsSyntaxErrors()
        {
            // Send the 'didOpen' event
            await this.SendOpenFileEvent(TestUtilities.NormalizePath("TestFiles/SimpleSyntaxError.ps1"), false);

            // Wait for the diagnostic event
            PublishDiagnosticsNotification diagnostics =
                await this.WaitForEvent(
                    PublishDiagnosticsNotification.Type);

            // Was there a syntax error?
            Assert.NotEmpty(diagnostics.Diagnostics);
            Assert.False(
                string.IsNullOrEmpty(diagnostics.Diagnostics[0].Message));
        }
 private bool ValidateNotification(PublishDiagnosticsNotification notif, int errors, ref int countOfValidationCalls)
 {
     countOfValidationCalls++;
     Assert.True(notif.Diagnostics.Length == errors, $"Notification errors {notif.Diagnostics.Length} are not as expected {errors}");
     return(true);
 }