Beispiel #1
0
        internal async Task GetCreationEffects_BasicTest_Package()
        {
            using Bootstrapper bootstrapper = BootstrapperFactory.GetBootstrapper();
            string packageLocation = await _packageManager.GetNuGetPackage("Microsoft.DotNet.Common.ProjectTemplates.5.0").ConfigureAwait(false);

            await bootstrapper.InstallTemplateAsync(packageLocation).ConfigureAwait(false);

            string output = TestUtils.CreateTemporaryFolder();

            var foundTemplates = await bootstrapper.GetTemplatesAsync(new[] { WellKnownSearchFilters.NameFilter("console") }).ConfigureAwait(false);

            var result = await bootstrapper.GetCreationEffectsAsync(foundTemplates[0].Info, "test", output, new Dictionary <string, string>(), "").ConfigureAwait(false);

            Assert.Equal(2, result.CreationResult.PrimaryOutputs.Count);
            Assert.Equal(2, result.CreationResult.PostActions.Count);
            Assert.Equal(2, result.FileChanges.Count);

            var expectedFileChanges = new FileChange[]
            {
                new FileChange("Company.ConsoleApplication1.csproj", "test.csproj", ChangeKind.Create),
                new FileChange("Program.cs", "Program.cs", ChangeKind.Create),
            };
            IFileChangeComparer comparer = new IFileChangeComparer();

            Assert.Equal(
                expectedFileChanges.OrderBy(s => s, comparer),
                result.FileChanges.OrderBy(s => s, comparer),
                comparer);
        }
Beispiel #2
0
        internal async Task GetCreationEffects_BasicTest_Folder()
        {
            using Bootstrapper bootstrapper = BootstrapperFactory.GetBootstrapper();
            await bootstrapper.InstallTestTemplateAsync("TemplateWithSourceName").ConfigureAwait(false);

            string output         = TestUtils.CreateTemporaryFolder();
            var    foundTemplates = await bootstrapper.GetTemplatesAsync(
                new[] { WellKnownSearchFilters.NameFilter("TestAssets.TemplateWithSourceName") }).ConfigureAwait(false);

            var result = await bootstrapper.GetCreationEffectsAsync(foundTemplates[0].Info, "test", output, new Dictionary <string, string>(), "").ConfigureAwait(false);

            Assert.Equal(2, result.CreationResult.PrimaryOutputs.Count);
            Assert.Equal(0, result.CreationResult.PostActions.Count);
            Assert.Equal(2, result.FileChanges.Count);

            var expectedFileChanges = new FileChange[]
            {
                new FileChange("bar.cs", "test.cs", ChangeKind.Create),
                new FileChange("bar/bar.cs", "test/test.cs", ChangeKind.Create),
            };
            IFileChangeComparer comparer = new IFileChangeComparer();

            Assert.Equal(
                expectedFileChanges.OrderBy(s => s, comparer),
                result.FileChanges.OrderBy(s => s, comparer),
                comparer);
        }
Beispiel #3
0
        internal async Task GetCreationEffectsTest(string templateName, string parameters, MockCreationEffects expectedResult)
        {
            Bootstrapper bootstrapper = BootstrapperFactory.GetBootstrapper();

            bootstrapper.InstallTestTemplate(templateName);

            string name   = BasicParametersParser.GetNameFromParameterString(parameters);
            string output = BasicParametersParser.GetOutputFromParameterString(parameters);
            Dictionary <string, string> parametersDict = BasicParametersParser.ParseParameterString(parameters);


            ITemplateInfo    template = bootstrapper.ListTemplates(true, WellKnownSearchFilters.NameFilter(templateName)).First().Info;
            ICreationEffects result   = await bootstrapper.GetCreationEffectsAsync(template, name, output, parametersDict, "").ConfigureAwait(false);

            Assert.Equal(expectedResult.CreationResult.PrimaryOutputs.Count, result.CreationResult.PrimaryOutputs.Count);
            Assert.Equal(
                expectedResult.CreationResult.PrimaryOutputs.Select(po => po.Path).OrderBy(s => s, StringComparer.OrdinalIgnoreCase),
                result.CreationResult.PrimaryOutputs.Select(po => po.Path).OrderBy(s => s, StringComparer.OrdinalIgnoreCase),
                StringComparer.OrdinalIgnoreCase);


            IFileChangeComparer comparer = new IFileChangeComparer();

            Assert.Equal(expectedResult.FileChanges.Count, result.FileChanges.Count);
            Assert.Equal(
                expectedResult.FileChanges.OrderBy(s => s, comparer),
                result.FileChanges.OrderBy(s => s, comparer),
                comparer);
        }
        internal async Task GetCreationEffectsTest_Package(string templateName, string parameters, MockCreationEffects expectedResult)
        {
            using Bootstrapper bootstrapper = BootstrapperFactory.GetBootstrapper();
            string packageLocation = _packageManager.PackTestTemplatesNuGetPackage();
            await bootstrapper.InstallTemplateAsync(packageLocation).ConfigureAwait(false);

            string name   = BasicParametersParser.GetNameFromParameterString(parameters);
            string output = BasicParametersParser.GetOutputFromParameterString(parameters);
            Dictionary <string, string> parametersDict = BasicParametersParser.ParseParameterString(parameters);

            var foundTemplates = await bootstrapper.GetTemplatesAsync(new[] { WellKnownSearchFilters.NameFilter(templateName) }).ConfigureAwait(false);

            ITemplateInfo    template = foundTemplates.Single(template => template.Info.ShortNameList.Contains($"TestAssets.{templateName}")).Info;
            ICreationEffects result   = await bootstrapper.GetCreationEffectsAsync(template, name, output, parametersDict, "").ConfigureAwait(false);

            Assert.Equal(expectedResult.CreationResult.PrimaryOutputs.Count, result.CreationResult.PrimaryOutputs.Count);
            Assert.Equal(
                expectedResult.CreationResult.PrimaryOutputs.Select(po => po.Path).OrderBy(s => s, StringComparer.OrdinalIgnoreCase),
                result.CreationResult.PrimaryOutputs.Select(po => po.Path).OrderBy(s => s, StringComparer.OrdinalIgnoreCase),
                StringComparer.OrdinalIgnoreCase);

            IFileChangeComparer comparer = new IFileChangeComparer();

            Assert.Equal(expectedResult.FileChanges.Count, result.FileChanges.Count);
            Assert.Equal(
                expectedResult.FileChanges.OrderBy(s => s, comparer),
                result.FileChanges.OrderBy(s => s, comparer),
                comparer);
        }
Beispiel #5
0
        internal async Task GetCreationEffects_BasicTest_Package()
        {
            var    bootstrapper    = BootstrapperFactory.GetBootstrapper();
            string packageLocation = _packageManager.PackProjectTemplatesNuGetPackage("microsoft.dotnet.common.projecttemplates.5.0");

            bootstrapper.InstallTemplate(packageLocation);

            string output   = TestHelper.CreateTemporaryFolder();
            var    template = bootstrapper.ListTemplates(true, WellKnownSearchFilters.NameFilter("console"));
            var    result   = await bootstrapper.GetCreationEffectsAsync(template.First().Info, "test", output, new Dictionary <string, string>(), "").ConfigureAwait(false);

            Assert.Equal(2, result.CreationResult.PrimaryOutputs.Count);
            Assert.Equal(2, result.CreationResult.PostActions.Count);
            Assert.Equal(2, result.FileChanges.Count);

            var expectedFileChanges = new FileChange[]
            {
                new FileChange("Company.ConsoleApplication1.csproj", "test.csproj", ChangeKind.Create),
                new FileChange("Program.cs", "Program.cs", ChangeKind.Create),
            };
            IFileChangeComparer comparer = new IFileChangeComparer();

            Assert.Equal(
                expectedFileChanges.OrderBy(s => s, comparer),
                result.FileChanges.OrderBy(s => s, comparer),
                comparer);
        }