예제 #1
0
        /// <summary>
        /// Get the Pester CodeLenses for a given Pester symbol.
        /// </summary>
        /// <param name="pesterSymbol">The Pester symbol to get CodeLenses for.</param>
        /// <param name="scriptFile">The script file the Pester symbol comes from.</param>
        /// <returns>All CodeLenses for the given Pester symbol.</returns>
        private CodeLens[] GetPesterLens(
            PesterSymbolReference pesterSymbol,
            ScriptFile scriptFile)
        {
            var codeLensResults = new CodeLens[]
            {
                new CodeLens(
                    this,
                    scriptFile,
                    pesterSymbol.ScriptRegion,
                    new ClientCommand(
                        "PowerShell.RunPesterTests",
                        "Run tests",
                        new object[] { scriptFile.ClientFilePath, false /* No debug */, pesterSymbol.TestName })),

                new CodeLens(
                    this,
                    scriptFile,
                    pesterSymbol.ScriptRegion,
                    new ClientCommand(
                        "PowerShell.RunPesterTests",
                        "Debug tests",
                        new object[] { scriptFile.ClientFilePath, true /* Run in debugger */, pesterSymbol.TestName })),
            };

            return(codeLensResults);
        }
        /// <summary>
        /// Get the Pester CodeLenses for a given Pester symbol.
        /// </summary>
        /// <param name="pesterSymbol">The Pester symbol to get CodeLenses for.</param>
        /// <param name="scriptFile">The script file the Pester symbol comes from.</param>
        /// <returns>All CodeLenses for the given Pester symbol.</returns>
        private static CodeLens[] GetPesterLens(PesterSymbolReference pesterSymbol, ScriptFile scriptFile)
        {
            string word = pesterSymbol.Command == PesterCommandType.It ? "test" : "tests";

            CodeLens[] codeLensResults = new CodeLens[]
            {
                new CodeLens()
                {
                    Range = pesterSymbol.ScriptRegion.ToRange(),
                    Data  = JToken.FromObject(new {
                        Uri        = scriptFile.DocumentUri,
                        ProviderId = nameof(PesterCodeLensProvider)
                    }, LspSerializer.Instance.JsonSerializer),
                    Command = new Command()
                    {
                        Name      = "PowerShell.RunPesterTests",
                        Title     = $"Run {word}",
                        Arguments = JArray.FromObject(new object[]
                        {
                            scriptFile.DocumentUri,
                            false /* No debug */,
                            pesterSymbol.TestName,
                            pesterSymbol.ScriptRegion?.StartLineNumber
                        }, LspSerializer.Instance.JsonSerializer)
                    }
                },

                new CodeLens()
                {
                    Range = pesterSymbol.ScriptRegion.ToRange(),
                    Data  = JToken.FromObject(new {
                        Uri        = scriptFile.DocumentUri,
                        ProviderId = nameof(PesterCodeLensProvider)
                    }, LspSerializer.Instance.JsonSerializer),
                    Command = new Command()
                    {
                        Name      = "PowerShell.RunPesterTests",
                        Title     = $"Debug {word}",
                        Arguments = JArray.FromObject(new object[]
                        {
                            scriptFile.DocumentUri,
                            true /* No debug */,
                            pesterSymbol.TestName,
                            pesterSymbol.ScriptRegion?.StartLineNumber
                        },
                                                      LspSerializer.Instance.JsonSerializer)
                    }
                }
            };

            return(codeLensResults);
        }
예제 #3
0
        /// <summary>
        /// Get the Pester CodeLenses for a given Pester symbol.
        /// </summary>
        /// <param name="pesterSymbol">The Pester symbol to get CodeLenses for.</param>
        /// <param name="scriptFile">The script file the Pester symbol comes from.</param>
        /// <returns>All CodeLenses for the given Pester symbol.</returns>
        private CodeLens[] GetPesterLens(PesterSymbolReference pesterSymbol, ScriptFile scriptFile)
        {
            var codeLensResults = new CodeLens[]
            {
                new CodeLens()
                {
                    Range = pesterSymbol.ScriptRegion.ToRange(),
                    Data  = JToken.FromObject(new {
                        Uri        = scriptFile.DocumentUri,
                        ProviderId = nameof(PesterCodeLensProvider)
                    }),
                    Command = new Command()
                    {
                        Name      = "PowerShell.RunPesterTests",
                        Title     = "Run tests",
                        Arguments = JArray.FromObject(new object[] {
                            scriptFile.DocumentUri,
                            false /* No debug */,
                            pesterSymbol.TestName,
                            pesterSymbol.ScriptRegion?.StartLineNumber
                        })
                    }
                },

                new CodeLens()
                {
                    Range = pesterSymbol.ScriptRegion.ToRange(),
                    Data  = JToken.FromObject(new {
                        Uri        = scriptFile.DocumentUri,
                        ProviderId = nameof(PesterCodeLensProvider)
                    }),
                    Command = new Command()
                    {
                        Name      = "PowerShell.RunPesterTests",
                        Title     = "Debug tests",
                        Arguments = JArray.FromObject(new object[] {
                            scriptFile.DocumentUri,
                            true /* No debug */,
                            pesterSymbol.TestName,
                            pesterSymbol.ScriptRegion?.StartLineNumber
                        })
                    }
                }
            };

            return(codeLensResults);
        }
        private IEnumerable <CodeLens> GetPesterLens(
            PesterSymbolReference pesterSymbol,
            ScriptFile scriptFile)
        {
            var clientCommands = new ClientCommand[]
            {
                new ClientCommand(
                    "PowerShell.RunPesterTests",
                    "Run tests",
                    new object[]
                {
                    scriptFile.ClientFilePath,
                    false,     // Don't debug
                    pesterSymbol.TestName,
                }),

                new ClientCommand(
                    "PowerShell.RunPesterTests",
                    "Debug tests",
                    new object[]
                {
                    scriptFile.ClientFilePath,
                    true,     // Run in debugger
                    pesterSymbol.TestName,
                }),
            };

            return
                (clientCommands.Select(
                     command =>
                     new CodeLens(
                         this,
                         scriptFile,
                         pesterSymbol.ScriptRegion,
                         command)));
        }