Ejemplo n.º 1
0
 public static async Task <Package> XunitWorkspaceCopy([CallerMemberName] string testName = null) =>
 await PackageUtilities.Copy(
     await Default.XunitWorkspace(),
     testName);
Ejemplo n.º 2
0
 public static async Task <Package> ConsoleWorkspaceCopy([CallerMemberName] string testName = null, bool isRebuildable = false, IScheduler buildThrottleScheduler = null) =>
 await PackageUtilities.Copy(
     await Default.ConsoleWorkspace(),
     testName,
     isRebuildable,
     buildThrottleScheduler);
Ejemplo n.º 3
0
 public static async Task <Package> WebApiWorkspaceCopy([CallerMemberName] string testName = null) =>
 await Package.Copy(
     await Default.WebApiWorkspace(),
     testName);
        public async Task Get_documentation_with_signature_help_for_console_writeline()
        {
            #region bufferSources

            var program = @"using System;
using System.Linq;

namespace FibonacciTest
{
    public class Program
    {
        public static void Main()
        {
            foreach (var i in FibonacciGenerator.Fibonacci().Take(20))
            {
                Console.WriteLine(i);
            }
        }
    }
}".EnforceLF();

            var generator = @"using System.Collections.Generic;
using System;
namespace FibonacciTest
{
    public static class FibonacciGenerator
    {
        public static IEnumerable<int> Fibonacci()
        {
            int current = 1, next = 1;
            while (true)
            {
                yield return current;
                next = current + (current = next);
                Console.WriteLine($$);
            }
        }
    }
}".EnforceLF();

            #endregion

            var(processed, position) = CodeManipulation.ProcessMarkup(generator);
            var package = await PackageUtilities.Copy(await Default.ConsoleWorkspace());

            var workspace = new Workspace(workspaceType: package.Name, buffers: new[]
            {
                new Buffer("Program.cs", program),
                new Buffer("generators/FibonacciGenerator.cs", processed, position)
            });

            var request = new WorkspaceRequest(workspace, activeBufferId: "generators/FibonacciGenerator.cs");
            var server  = await GetLanguageServiceAsync();

            var result = await server.GetSignatureHelp(request);

            result.Signatures.Should().NotBeNullOrEmpty();

            var sample = result.Signatures.First(e => e.Label == "void Console.WriteLine(string format, params object[] arg)");
            sample.Documentation.Value.Should().Contain("Writes the text representation of the specified array of objects, followed by the current line terminator, to the standard output stream using the specified format information.");
            sample.Parameters.Should().HaveCount(2);

            sample.Parameters.ElementAt(0).Name.Should().Be("format");
            sample.Parameters.ElementAt(0).Label.Should().Be("string format");
            sample.Parameters.ElementAt(0).Documentation.Value.Should().Contain("A composite format string.");

            sample.Parameters.ElementAt(1).Name.Should().Be("arg");
            sample.Parameters.ElementAt(1).Label.Should().Be("params object[] arg");
            sample.Parameters.ElementAt(1).Documentation.Value.Should().Contain("An array of objects to write using format .");
        }
        public async Task Get_documentation_with_autocompletion_of_console_methods()
        {
            #region bufferSources

            var program = @"using System;
using System.Linq;

namespace FibonacciTest
{
    public class Program
    {
        public static void Main()
        {
            foreach (var i in FibonacciGenerator.Fibonacci().Take(20))
            {
                Console.WriteLine(i);
            }
        }
    }
}".EnforceLF();

            var generator = @"using System.Collections.Generic;
using System;
namespace FibonacciTest
{
    public static class FibonacciGenerator
    {
        public static IEnumerable<int> Fibonacci()
        {
            int current = 1, next = 1;
            while (true)
            {
                yield return current;
                next = current + (current = next);
                Console.$$
            }
        }
    }
}".EnforceLF();

            #endregion

            var package = await Package.Copy(await Default.ConsoleWorkspace());

            var(processed, position) = CodeManipulation.ProcessMarkup(generator);

            var workspace = new Workspace(workspaceType: package.Name, buffers: new[]
            {
                new Buffer("Program.cs", program),
                new Buffer("generators/FibonacciGenerator.cs", processed, position)
            });

            var request = new WorkspaceRequest(workspace, activeBufferId: "generators/FibonacciGenerator.cs");
            var server  = GetLanguageService();
            var result  = await server.GetCompletionList(request);

            result.Should().NotBeNull();
            result.Items.Should().NotBeNullOrEmpty();

            result.Items
            .Where(i => i.Documentation != null && !string.IsNullOrWhiteSpace(i.Documentation.Value))
            .Select(i => i.Documentation.Value)
            .Should()
            .Contain(d => d == "Writes the text representation of the specified Boolean value to the standard output stream.");
        }