public async Task WhenAddingANewProfile_AndAProfileNameIsProvided_TheProvidedNameIsUsed()
        {
            var            project    = UnconfiguredProjectFactory.Create();
            ILaunchProfile?newProfile = null;

            var profiles = new List <ILaunchProfile>();
            var launchSettingsProvider = ILaunchSettingsProviderFactory.Create(
                addOrUpdateProfileCallback: (profile, addToFront) => { profiles.Add(profile); newProfile = profile; },
                getProfilesCallback: (p) => ImmutableList.CreateRange(profiles));

            var queryVersionProvider = new LaunchSettingsQueryVersionProvider();
            var tracker = new LaunchSettingsTracker(project, launchSettingsProvider, queryVersionProvider);

            var handler = new ProjectLaunchProfileHandler(project, launchSettingsProvider, tracker);

            var context = IQueryExecutionContextFactory.Create();
            var parent  = IEntityWithIdFactory.Create("Project", "MyProject");

            var newProfileId = await handler.AddLaunchProfileAsync(context, parent, commandName : "Alpha", newProfileName : "Beta");

            Assert.NotNull(newProfile);
            Assert.Equal(expected: "Beta", actual: newProfile.Name);
            Assert.Equal(expected: "Alpha", actual: newProfile.CommandName);
            Assert.Single(profiles);

            Assert.NotNull(newProfileId);
            Assert.Equal(expected: "LaunchProfile", actual: newProfileId[ProjectModelIdentityKeys.SourceItemType]);
            Assert.Equal(expected: "Beta", actual: newProfileId[ProjectModelIdentityKeys.SourceItemName]);
        }
Exemple #2
0
        public async Task WhenAskedForLaunchProfileItemTypes_GetItemsAsyncReturnsAnItemForEachProfile()
        {
            var profile1 = new WritableLaunchProfile {
                Name = "Profile1"
            };
            var profile2 = new WritableLaunchProfile {
                Name = "Profile2"
            };
            var launchSettingsProvider = ILaunchSettingsProviderFactory.Create(
                launchProfiles: new[] { profile1.ToLaunchProfile(), profile2.ToLaunchProfile() });

            var itemProvider = new LaunchProfileProjectItemProvider(
                UnconfiguredProjectFactory.Create(),
                launchSettingsProvider);

            var items = await itemProvider.GetItemsAsync(LaunchProfileProjectItemProvider.ItemType);

            Assert.Collection(items,
                              item => Assert.Equal("Profile1", item.EvaluatedInclude),
                              item => Assert.Equal("Profile2", item.EvaluatedInclude));

            items = await itemProvider.GetItemsAsync(LaunchProfileProjectItemProvider.ItemType, "Profile2");

            Assert.Collection(items,
                              item => Assert.Equal("Profile2", item.EvaluatedInclude));
        }
Exemple #3
0
        public async Task WhenProjectPropertyContextHasTheWrongItemType_GetItemsAsyncReturnsNull()
        {
            var profile1 = new WritableLaunchProfile {
                Name = "Profile1"
            };
            var profile2 = new WritableLaunchProfile {
                Name = "Profile2"
            };
            var launchSettingsProvider = ILaunchSettingsProviderFactory.Create(
                launchProfiles: new[] { profile1.ToLaunchProfile(), profile2.ToLaunchProfile() });

            var itemProvider = new LaunchProfileProjectItemProvider(
                UnconfiguredProjectFactory.Create(),
                launchSettingsProvider);

            var context = new TestProjectPropertiesContext(
                isProjectFile: true,
                file: "Foo",
                itemType: "RandomItemType",
                itemName: "Profile2");

            var item = await itemProvider.GetItemAsync(context);

            Assert.Null(item);
        }
        public async Task WhenDuplicatingAProfile_AndNameAndCommandAreProvided_TheNameAndCommandAreUsed()
        {
            var            project           = UnconfiguredProjectFactory.Create();
            ILaunchProfile?duplicatedProfile = null;

            var profiles = new List <ILaunchProfile>
            {
                new WritableLaunchProfile {
                    Name = "Alpha", CommandName = "Beta", ExecutablePath = @"C:\iguana\aardvark.exe"
                }.ToLaunchProfile()
            };
            var launchSettingsProvider = ILaunchSettingsProviderFactory.Create(
                launchProfiles: profiles,
                addOrUpdateProfileCallback: (profile, addToFront) => { profiles.Add(profile); duplicatedProfile = profile; },
                getProfilesCallback: (p) => ImmutableList.CreateRange(profiles));

            var queryVersionProvider = new LaunchSettingsQueryVersionProvider();
            var tracker = new LaunchSettingsTracker(project, launchSettingsProvider, queryVersionProvider);

            var handler = new ProjectLaunchProfileHandler(project, launchSettingsProvider, tracker);

            var context = IQueryExecutionContextFactory.Create();
            var parent  = IEntityWithIdFactory.Create("Project", "MyProject");

            var duplicatedProfileId = await handler.DuplicateLaunchProfileAsync(context, parent, currentProfileName : "Alpha", newProfileName : "Gamma", newProfileCommandName : "Delta");

            Assert.Equal(expected: "Gamma", actual: duplicatedProfile !.Name);
            Assert.Equal(expected: "Delta", actual: duplicatedProfile !.CommandName);
            Assert.Equal(expected: @"C:\iguana\aardvark.exe", actual: duplicatedProfile !.ExecutablePath);
            Assert.Equal(expected: 2, actual: profiles.Count);

            Assert.NotNull(duplicatedProfileId);
            Assert.Equal(expected: "LaunchProfile", actual: duplicatedProfileId[ProjectModelIdentityKeys.SourceItemType]);
            Assert.Equal(expected: duplicatedProfile.Name, actual: duplicatedProfileId[ProjectModelIdentityKeys.SourceItemName]);
        }
Exemple #5
0
        public async Task WhenProjectPropertyContextHasLaunchProfileItemType_GetItemsAsyncReturnsAnItemWithAMatchingName()
        {
            var profile1 = new WritableLaunchProfile {
                Name = "Profile1"
            };
            var profile2 = new WritableLaunchProfile {
                Name = "Profile2"
            };
            var launchSettingsProvider = ILaunchSettingsProviderFactory.Create(
                launchProfiles: new[] { profile1.ToLaunchProfile(), profile2.ToLaunchProfile() });

            var itemProvider = new LaunchProfileProjectItemProvider(
                UnconfiguredProjectFactory.Create(),
                launchSettingsProvider);

            var context = new TestProjectPropertiesContext(
                isProjectFile: true,
                file: "Foo",
                itemType: LaunchProfileProjectItemProvider.ItemType,
                itemName: "Profile2");

            var item = await itemProvider.GetItemAsync(context);

            Assert.NotNull(item);
            Assert.Equal("Profile2", item.EvaluatedInclude);
        }
Exemple #6
0
        public async Task WhenRetrievingItemPropertyNames_AllStandardProfilePropertyNamesAreReturnedEvenIfNotDefined()
        {
            var profile1 = new WritableLaunchProfile {
                Name = "Profile1"
            };
            var launchSettingsProvider = ILaunchSettingsProviderFactory.Create(
                launchProfiles: new[] { profile1.ToLaunchProfile() });

            var properties = new LaunchProfileProjectProperties(
                DefaultTestProjectPath,
                "Profile1",
                launchSettingsProvider,
                EmptyLaunchProfileExtensionValueProviders,
                EmptyGlobalSettingExtensionValueProviders);

            var propertyNames = await properties.GetPropertyNamesAsync();

            Assert.Contains("CommandName", propertyNames);
            Assert.Contains("ExecutablePath", propertyNames);
            Assert.Contains("CommandLineArguments", propertyNames);
            Assert.Contains("WorkingDirectory", propertyNames);
            Assert.Contains("LaunchBrowser", propertyNames);
            Assert.Contains("LaunchUrl", propertyNames);
            Assert.Contains("EnvironmentVariables", propertyNames);
        }
Exemple #7
0
        public async Task WhenRetrievingStandardPropertyValues_TheEmptyStringIsReturnedForUndefinedProperties()
        {
            var profile1 = new WritableLaunchProfile {
                Name = "Profile1"
            };
            var launchSettingsProvider = ILaunchSettingsProviderFactory.Create(
                launchProfiles: new[] { profile1.ToLaunchProfile() });

            var properties = new LaunchProfileProjectProperties(
                DefaultTestProjectPath,
                "Profile1",
                launchSettingsProvider,
                EmptyLaunchProfileExtensionValueProviders,
                EmptyGlobalSettingExtensionValueProviders);

            var standardPropertyNames = new[]
            {
                "CommandName",
                "ExecutablePath",
                "CommandLineArguments",
                "WorkingDirectory",
                "LaunchUrl",
                "EnvironmentVariables"
            };

            foreach (var standardPropertyName in standardPropertyNames)
            {
                var evaluatedValue = await properties.GetEvaluatedPropertyValueAsync(standardPropertyName);

                Assert.Equal(expected: string.Empty, actual: evaluatedValue);
                var unevaluatedValue = await properties.GetUnevaluatedPropertyValueAsync(standardPropertyName);

                Assert.Equal(expected: string.Empty, actual: unevaluatedValue);
            }
        }
Exemple #8
0
        public async Task WhenSettingValuesNotHandledByExtenders_ValuesOfTheExpectedTypesAreStoredInOtherSettings()
        {
            var writableProfile = new WritableLaunchProfile
            {
                Name = "Profile1",
            };
            var launchSettingsProvider = ILaunchSettingsProviderFactory.Create(
                launchProfiles: new[] { writableProfile.ToLaunchProfile() },
                tryUpdateProfileCallback: (profile, action) =>
            {
                // Update writableProfile since we're hanging on to it rather than the profile given us by the mock.
                action(writableProfile);
            });

            var rule = new Rule
            {
                Properties =
                {
                    new IntProperty    {
                        Name = "anInteger"
                    },
                    new BoolProperty   {
                        Name = "aBoolean"
                    },
                    new StringProperty {
                        Name = "aString"
                    },
                    new EnumProperty   {
                        Name = "anEnumStoredAsAString"
                    }
                    // anotherString intentionally not represented
                }
            };

            var properties = new LaunchProfileProjectProperties(
                DefaultTestProjectPath,
                "Profile1",
                launchSettingsProvider,
                EmptyLaunchProfileExtensionValueProviders,
                EmptyGlobalSettingExtensionValueProviders);

            properties.SetRuleContext(rule);

            await properties.SetPropertyValueAsync("anInteger", "2");

            await properties.SetPropertyValueAsync("aBoolean", "false");

            await properties.SetPropertyValueAsync("aString", "Hello, world!");

            await properties.SetPropertyValueAsync("anEnumStoredAsAString", "valueTwo");

            await properties.SetPropertyValueAsync("anotherString", "Hello, friends!");

            Assert.Equal(expected: 2, actual: writableProfile.OtherSettings["anInteger"]);
            Assert.Equal(expected: false, actual: writableProfile.OtherSettings["aBoolean"]);
            Assert.Equal(expected: "Hello, world!", actual: writableProfile.OtherSettings["aString"]);
            Assert.Equal(expected: "valueTwo", actual: writableProfile.OtherSettings["anEnumStoredAsAString"]);
            Assert.Equal(expected: "Hello, friends!", actual: writableProfile.OtherSettings["anotherString"]);
        }
Exemple #9
0
        public async Task GetItemTypesAsync_ReturnsLaunchProfile()
        {
            var itemProvider = new LaunchProfileProjectItemProvider(
                UnconfiguredProjectFactory.Create(),
                ILaunchSettingsProviderFactory.Create());

            var itemTypes = await itemProvider.GetItemTypesAsync();

            Assert.Single(itemTypes, LaunchProfileProjectItemProvider.ItemType);
        }
Exemple #10
0
        public void DefaultProjectPath_IsTheProjectPath()
        {
            var provider = new LaunchProfileProjectPropertiesProvider(
                CreateDefaultTestProject(),
                ILaunchSettingsProviderFactory.Create(),
                EmptyLaunchProfileExtensionValueProviders,
                EmptyGlobalSettingExtensionValueProviders);

            var defaultProjectPath = provider.DefaultProjectPath;

            Assert.Equal(expected: DefaultTestProjectPath, actual: defaultProjectPath);
        }
Exemple #11
0
        public void WhenRetrievingItemProperties_NullIsReturnedIfTheItemIsNull()
        {
            var project  = UnconfiguredProjectFactory.Create();
            var provider = new LaunchProfileProjectPropertiesProvider(
                project,
                ILaunchSettingsProviderFactory.Create(),
                EmptyLaunchProfileExtensionValueProviders,
                EmptyGlobalSettingExtensionValueProviders);

            var itemProperties = provider.GetItemProperties(LaunchProfileProjectItemProvider.ItemType, item: null);

            Assert.Null(itemProperties);
        }
Exemple #12
0
        public void WhenRetrievingProjectLevelProperties_NullIsReturned()
        {
            var project  = UnconfiguredProjectFactory.Create();
            var provider = new LaunchProfileProjectPropertiesProvider(
                project,
                ILaunchSettingsProviderFactory.Create(),
                EmptyLaunchProfileExtensionValueProviders,
                EmptyGlobalSettingExtensionValueProviders);

            var commonProperties = provider.GetCommonProperties();

            Assert.Null(commonProperties);
        }
Exemple #13
0
        public async Task WhenThereAreNoLaunchProfiles_GetItemsAsyncReturnsAnEmptyEnumerable()
        {
            var launchSettingsProvider = ILaunchSettingsProviderFactory.Create(
                launchProfiles: new LaunchProfile[0]);

            var itemProvider = new LaunchProfileProjectItemProvider(
                UnconfiguredProjectFactory.Create(),
                launchSettingsProvider);

            var items = await itemProvider.GetItemsAsync();

            Assert.Empty(items);
        }
Exemple #14
0
        public async Task WhenThereAreNoLaunchProfiles_GetExistingItemTypesAsyncReturnsAnEmptySet()
        {
            var launchSettingsProvider = ILaunchSettingsProviderFactory.Create(
                launchProfiles: new LaunchProfile[0]);

            var itemProvider = new LaunchProfilesProjectItemProvider(
                UnconfiguredProjectFactory.Create(),
                launchSettingsProvider);

            var existingItemTypes = await itemProvider.GetExistingItemTypesAsync();

            Assert.Empty(existingItemTypes);
        }
Exemple #15
0
        /// <summary>
        /// Creates an <see cref="ILaunchSettingsProvider"/> with two empty profiles named
        /// "Profile1" and "Profile2".
        /// </summary>
        private static ILaunchSettingsProvider3 CreateDefaultTestLaunchSettings()
        {
            var profile1 = new WritableLaunchProfile {
                Name = "Profile1"
            };
            var profile2 = new WritableLaunchProfile {
                Name = "Profile2"
            };
            var launchSettingsProvider = ILaunchSettingsProviderFactory.Create(
                launchProfiles: new[] { profile1.ToLaunchProfile(), profile2.ToLaunchProfile() });

            return(launchSettingsProvider);
        }
Exemple #16
0
        public async Task WhenAddingAnItem_AnExceptionIsThrownIfTheItemTypeIsWrong()
        {
            var launchSettingsProvider = ILaunchSettingsProviderFactory.Create();

            var itemProvider = new LaunchProfileProjectItemProvider(
                UnconfiguredProjectFactory.Create(),
                launchSettingsProvider);

            await Assert.ThrowsAsync <ArgumentException>(async() =>
            {
                var item = await itemProvider.AddAsync(itemType: "RandomItemType", include: "Alpha Profile");
            });
        }
        public async Task WhenAddingANewProfile_AndAProfileNameIsProvided_TheProvidedNameIsUsed()
        {
            var profiles = new List <ILaunchProfile>();
            var launchSettingsProvider = ILaunchSettingsProviderFactory.Create(
                addOrUpdateProfileCallback: (profile, addToFront) => profiles.Add(profile),
                getProfilesCallback: (p) => ImmutableList.CreateRange(profiles));
            var service = new LaunchSettingsActionService(launchSettingsProvider);

            var newProfile = await service.AddLaunchProfileAsync(commandName : "Alpha", newProfileName : "Beta");

            Assert.NotNull(newProfile);
            Assert.Equal(expected: "Beta", actual: newProfile !.Name);
            Assert.Equal(expected: "Alpha", actual: newProfile !.CommandName);
            Assert.Single(profiles);
        }
Exemple #18
0
        public async Task WhenThereAreLaunchProfiles_GetExistingItemTypesAsyncReturnsASingleItem()
        {
            var profile = new WritableLaunchProfile {
                Name = "Test"
            };
            var launchSettingsProvider = ILaunchSettingsProviderFactory.Create(
                launchProfiles: new[] { profile.ToLaunchProfile() });

            var itemProvider = new LaunchProfileProjectItemProvider(
                UnconfiguredProjectFactory.Create(),
                launchSettingsProvider);

            var existingItemTypes = await itemProvider.GetExistingItemTypesAsync();

            Assert.Single(existingItemTypes, LaunchProfileProjectItemProvider.ItemType);
        }
Exemple #19
0
        public async Task WhenRetrievingStandardPropertyValues_TheExpectedValuesAreReturned()
        {
            var profile1 = new WritableLaunchProfile
            {
                Name                 = "Profile1",
                CommandLineArgs      = "alpha beta gamma",
                CommandName          = "epsilon",
                EnvironmentVariables = { ["One"] = "1", ["Two"] = "2" },
                ExecutablePath       = @"D:\five\six\seven\eight.exe",
                LaunchBrowser        = true,
                LaunchUrl            = "https://localhost/profile",
                WorkingDirectory     = @"C:\users\other\temp"
            };

            var launchSettingsProvider = ILaunchSettingsProviderFactory.Create(
                launchProfiles: new[] { profile1.ToLaunchProfile() });
            var properties = new LaunchProfileProjectProperties(
                DefaultTestProjectPath,
                "Profile1",
                launchSettingsProvider,
                EmptyLaunchProfileExtensionValueProviders,
                EmptyGlobalSettingExtensionValueProviders);

            var expectedValues = new Dictionary <string, string>
            {
                ["CommandLineArguments"] = "alpha beta gamma",
                ["CommandName"]          = "epsilon",
                ["EnvironmentVariables"] = "One=1,Two=2",
                ["ExecutablePath"]       = @"D:\five\six\seven\eight.exe",
                ["LaunchBrowser"]        = "true",
                ["LaunchUrl"]            = "https://localhost/profile",
                ["WorkingDirectory"]     = @"C:\users\other\temp",
            };

            foreach (var(propertyName, expectedPropertyValue) in expectedValues)
            {
                var actualUnevaluatedValue = await properties.GetUnevaluatedPropertyValueAsync(propertyName);

                var actualEvaluatedValue = await properties.GetEvaluatedPropertyValueAsync(propertyName);

                Assert.Equal(expectedPropertyValue, actualUnevaluatedValue);
                Assert.Equal(expectedPropertyValue, actualEvaluatedValue);
            }
        }
Exemple #20
0
        private static ILaunchSettingsProvider SetupLaunchSettingsProvider(
            string activeProfileName,
            string?activeProfileLaunchTarget         = null,
            string?activeProfileExecutablePath       = null,
            string?activeProfileCommandLineArgs      = null,
            string?activeProfileWorkingDirectory     = null,
            Action <string>?setActiveProfileCallback = null,
            Action <ILaunchSettings>?updateLaunchSettingsCallback = null)
        {
            var profile = new WritableLaunchProfile
            {
                Name           = activeProfileName,
                CommandName    = activeProfileLaunchTarget,
                ExecutablePath = activeProfileExecutablePath
            };

            if (activeProfileLaunchTarget != null)
            {
                profile.CommandName = activeProfileLaunchTarget;
            }

            if (activeProfileExecutablePath != null)
            {
                profile.ExecutablePath = activeProfileExecutablePath;
            }

            if (activeProfileCommandLineArgs != null)
            {
                profile.CommandLineArgs = activeProfileCommandLineArgs;
            }

            if (activeProfileWorkingDirectory != null)
            {
                profile.WorkingDirectory = activeProfileWorkingDirectory;
            }

            var settingsProvider = ILaunchSettingsProviderFactory.Create(
                activeProfileName,
                new[] { profile.ToLaunchProfile() },
                updateLaunchSettingsCallback: updateLaunchSettingsCallback,
                setActiveProfileCallback: setActiveProfileCallback);

            return(settingsProvider);
        }
Exemple #21
0
        public async Task WhenFindingAnItemByName_NullIsReturnedIfNoMatchingItemExists()
        {
            var profile1 = new WritableLaunchProfile {
                Name = "Profile1"
            };
            var profile2 = new WritableLaunchProfile {
                Name = "Profile2"
            };
            var launchSettingsProvider = ILaunchSettingsProviderFactory.Create(
                launchProfiles: new[] { profile1.ToLaunchProfile(), profile2.ToLaunchProfile() });

            var itemProvider = new LaunchProfileProjectItemProvider(
                UnconfiguredProjectFactory.Create(),
                launchSettingsProvider);

            var item = await itemProvider.FindItemByNameAsync("Profile3");

            Assert.Null(item);
        }
        public async Task WhenRemovingAProfile_TheProfileIsRemoved()
        {
            var profiles = new List <ILaunchProfile>
            {
                new WritableLaunchProfile {
                    Name = "Alpha", CommandName = "Beta", ExecutablePath = @"C:\iguana\aardvark.exe"
                }.ToLaunchProfile()
            };
            var launchSettingsProvider = ILaunchSettingsProviderFactory.Create(
                launchProfiles: profiles,
                addOrUpdateProfileCallback: (profile, addToFront) => profiles.Add(profile),
                removeProfileCallback: (removedProfileName) => profiles.RemoveAll(p => p.Name == removedProfileName),
                getProfilesCallback: (p) => ImmutableList.CreateRange(profiles));
            var service = new LaunchSettingsActionService(launchSettingsProvider);

            await service.RemoveLaunchProfileAsync(profileName : "Alpha");

            Assert.Empty(profiles);
        }
Exemple #23
0
        public async Task WhenFindingAnItemByName_TheMatchingItemIsReturnedIfItExists()
        {
            var profile1 = new WritableLaunchProfile {
                Name = "Profile1"
            };
            var profile2 = new WritableLaunchProfile {
                Name = "Profile2"
            };
            var launchSettingsProvider = ILaunchSettingsProviderFactory.Create(
                launchProfiles: new[] { profile1.ToLaunchProfile(), profile2.ToLaunchProfile() });

            var itemProvider = new LaunchProfileProjectItemProvider(
                UnconfiguredProjectFactory.Create(),
                launchSettingsProvider);

            var item = await itemProvider.FindItemByNameAsync("Profile2");

            Assert.NotNull(item);
            Assert.Equal(expected: "Profile2", actual: item.EvaluatedInclude);
        }
Exemple #24
0
        public async Task WhenSettingStandardPropertyValues_StandardCallbacksAreFound()
        {
            var profile1 = new WritableLaunchProfile
            {
                Name        = "Profile1",
                CommandName = "epsilon",
            };

            bool callbackInvoked;
            var  launchSettingsProvider = ILaunchSettingsProviderFactory.Create(
                launchProfiles: new[] { profile1.ToLaunchProfile() },
                tryUpdateProfileCallback: (profile, action) =>
            {
                callbackInvoked = true;
            });
            var properties = new LaunchProfileProjectProperties(
                DefaultTestProjectPath,
                "Profile1",
                launchSettingsProvider,
                EmptyLaunchProfileExtensionValueProviders,
                EmptyGlobalSettingExtensionValueProviders);

            var newValues = new Dictionary <string, string>
            {
                ["CommandLineArguments"] = "delta epsilon",
                ["CommandName"]          = "arugula",
                ["EnvironmentVariables"] = "Three=3,Four=4",
                ["ExecutablePath"]       = @"D:\nine\ten.exe",
                ["LaunchBrowser"]        = "false",
                ["LaunchUrl"]            = "https://localhost/myOtherProfile",
                ["WorkingDirectory"]     = @"D:\aardvark",
            };

            foreach (var(propertyName, newPropertyValue) in newValues)
            {
                callbackInvoked = false;
                await properties.SetPropertyValueAsync(propertyName, newPropertyValue);

                Assert.True(callbackInvoked);
            }
        }
        public async Task WhenDuplicatingAProfile_AndNameAndCommandAreProvided_TheNameAndCommandAreUsed()
        {
            var profiles = new List <ILaunchProfile>
            {
                new WritableLaunchProfile {
                    Name = "Alpha", CommandName = "Beta", ExecutablePath = @"C:\iguana\aardvark.exe"
                }.ToLaunchProfile()
            };
            var launchSettingsProvider = ILaunchSettingsProviderFactory.Create(
                launchProfiles: profiles,
                addOrUpdateProfileCallback: (profile, addToFront) => profiles.Add(profile),
                getProfilesCallback: (p) => ImmutableList.CreateRange(profiles));
            var service = new LaunchSettingsActionService(launchSettingsProvider);

            var duplicatedProfile = await service.DuplicateLaunchProfileAsync(currentProfileName : "Alpha", newProfileName : "Gamma", newProfileCommandName : "Delta");

            Assert.Equal(expected: "Gamma", actual: duplicatedProfile !.Name);
            Assert.Equal(expected: "Delta", actual: duplicatedProfile !.CommandName);
            Assert.Equal(expected: @"C:\iguana\aardvark.exe", actual: duplicatedProfile !.ExecutablePath);
            Assert.Equal(expected: 2, actual: profiles.Count);
        }
Exemple #26
0
        public async Task WhenRetrievingPropertyNames_PropertiesInOtherSettingsAreIncluded()
        {
            var profile1 = new WritableLaunchProfile
            {
                Name          = "Profile1",
                OtherSettings = { { "alpha", 1 } }
            };
            var launchSettingsProvider = ILaunchSettingsProviderFactory.Create(
                launchProfiles: new[] { profile1.ToLaunchProfile() });

            var properties = new LaunchProfileProjectProperties(
                DefaultTestProjectPath,
                "Profile1",
                launchSettingsProvider,
                EmptyLaunchProfileExtensionValueProviders,
                EmptyGlobalSettingExtensionValueProviders);

            var names = await properties.GetPropertyNamesAsync();

            Assert.Contains("alpha", names);
        }
Exemple #27
0
        public async Task WhenRetrievingTheLaunchBrowserValue_TheDefaultValueIsFalse()
        {
            var profile1 = new WritableLaunchProfile {
                Name = "Profile1"
            };
            var launchSettingsProvider = ILaunchSettingsProviderFactory.Create(
                launchProfiles: new[] { profile1.ToLaunchProfile() });

            var properties = new LaunchProfileProjectProperties(
                DefaultTestProjectPath,
                "Profile1",
                launchSettingsProvider,
                EmptyLaunchProfileExtensionValueProviders,
                EmptyGlobalSettingExtensionValueProviders);

            var evaluatedValue = await properties.GetEvaluatedPropertyValueAsync("LaunchBrowser");

            Assert.Equal(expected: "false", actual: evaluatedValue);
            var unevaluatedValue = await properties.GetUnevaluatedPropertyValueAsync("LaunchBrowser");

            Assert.Equal(expected: "false", actual: unevaluatedValue);
        }
Exemple #28
0
        public async Task WhenRetrievingPropertyNames_PropertiesInGlobalSettingsAreNotIncluded()
        {
            var profile1 = new WritableLaunchProfile
            {
                Name          = "Profile1",
                OtherSettings = { { "alpha", 1 } }
            };
            var launchSettingsProvider = ILaunchSettingsProviderFactory.Create(
                launchProfiles: new[] { profile1.ToLaunchProfile() },
                globalSettings: ImmutableDictionary <string, object> .Empty.Add("beta", "value"));

            var properties = new LaunchProfileProjectProperties(
                DefaultTestProjectPath,
                "Profile1",
                launchSettingsProvider,
                EmptyLaunchProfileExtensionValueProviders,
                EmptyGlobalSettingExtensionValueProviders);

            var names = await properties.GetPropertyNamesAsync();

            Assert.DoesNotContain("beta", names);
        }
        private static ILaunchSettingsProvider SetupLaunchSettingsProvider(
            string activeProfileName,
            string?activeProfileLaunchTarget = null,
            Action <ILaunchSettings>?updateLaunchSettingsCallback = null)
        {
            var profile = new WritableLaunchProfile
            {
                Name = activeProfileName
            };

            if (activeProfileLaunchTarget != null)
            {
                profile.CommandName = activeProfileLaunchTarget;
            }

            var settingsProvider = ILaunchSettingsProviderFactory.Create(
                activeProfileName,
                new[] { profile.ToLaunchProfile() },
                updateLaunchSettingsCallback: updateLaunchSettingsCallback);

            return(settingsProvider);
        }
        public async Task WhenRenamingAProfile_TheOldProfileIsRemovedAndTheNewProfileIsAdded()
        {
            var profiles = new List <ILaunchProfile>
            {
                new WritableLaunchProfile {
                    Name = "Alpha", CommandName = "Beta", ExecutablePath = @"C:\iguana\aardvark.exe"
                }.ToLaunchProfile()
            };
            var launchSettingsProvider = ILaunchSettingsProviderFactory.Create(
                launchProfiles: profiles,
                addOrUpdateProfileCallback: (profile, addToFront) => profiles.Add(profile),
                removeProfileCallback: (removedProfileName) => profiles.RemoveAll(p => p.Name == removedProfileName),
                getProfilesCallback: (p) => ImmutableList.CreateRange(profiles));
            var service = new LaunchSettingsActionService(launchSettingsProvider);

            var renamedProfile = await service.RenameLaunchProfileAsync(currentProfileName : "Alpha", newProfileName : "Gamma");

            Assert.Equal(expected: "Gamma", actual: renamedProfile !.Name);
            Assert.Equal(expected: "Beta", actual: renamedProfile !.CommandName);
            Assert.Equal(expected: @"C:\iguana\aardvark.exe", actual: renamedProfile !.ExecutablePath);
            Assert.Single(profiles);
        }