Exemplo n.º 1
0
Arquivo: Create.cs Projeto: rlundy/try
        public static Package EmptyWorkspace([CallerMemberName] string testName = null, IPackageInitializer initializer = null, bool isRebuildablePackage = false)
        {
            if (!isRebuildablePackage)
            {
                return(new NonrebuildablePackage(directory: Package.CreateDirectory(testName), initializer: initializer));
            }

            return(new RebuildablePackage(directory: Package.CreateDirectory(testName), initializer: initializer));
        }
Exemplo n.º 2
0
        public async Task Workspaces_can_be_registered_to_be_created_using_dotnet_new()
        {
            var packageName = Package.CreateDirectory(nameof(Workspaces_can_be_registered_to_be_created_using_dotnet_new)).Name;

            registry.Add(packageName,
                         options => options.CreateUsingDotnet("console"));

            var package = await registry.Get <ICreateWorkspaceForRun>(packageName);

            var workspace = await package.CreateRoslynWorkspaceForRunAsync(new TimeBudget(30.Seconds()));

            var project = workspace.CurrentSolution.Projects.First();

            project.MetadataReferences.Count.Should().BeGreaterThan(0);
        }
Exemplo n.º 3
0
        public async Task Workspace_can_be_registered_in_directory_other_than_the_default()
        {
            var parentDirectory = Package.CreateDirectory(nameof(Workspace_can_be_registered_in_directory_other_than_the_default));

            var workspaceName = "a";

            var childDirectory = parentDirectory.CreateSubdirectory(workspaceName);

            registry.Add(
                workspaceName,
                builder =>
            {
                builder.Directory = childDirectory;
            });

            var workspace = await registry.Get <IHaveADirectory>(workspaceName);

            workspace.Directory.Should().Be(childDirectory);
        }
Exemplo n.º 4
0
        public async Task NuGet_packages_can_be_added_during_initialization()
        {
            var workspaceId = Package.CreateDirectory(nameof(NuGet_packages_can_be_added_during_initialization)).Name;

            registry.Add(workspaceId,
                         options =>
            {
                options.CreateUsingDotnet("console");
                options.AddPackageReference("Twilio", "5.9.2");
            });

            var workspaceServer = new RoslynWorkspaceServer(registry);

            var workspace = Workspace.FromSource(
                @"
using System;
using Twilio.Clients;
using Twilio.Rest.Api.V2010.Account;
using Twilio.Types;

namespace Twilio_try.dot.net_sample
{
    class Program
    {
        static void Main()
        {
            var sendFromPhoneNumber = new PhoneNumber(""TWILIO_PHONE_NUMBER"");
            var sendToPhoneNumber = new PhoneNumber(""RECIPIENT_PHONE_NUMBER"");
        }
    }
}",
                workspaceType: workspaceId);

            var result = await workspaceServer.Run(new WorkspaceRequest(workspace));

            result.Succeeded.Should().BeTrue(because: "compilation can't succeed unless the NuGet package has been restored.");
        }