Esempio n. 1
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);
            }
        }
Esempio n. 2
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);
        }
Esempio n. 3
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));
        }
Esempio n. 4
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);
        }
Esempio n. 5
0
        public async Task <(EntityIdentity oldProfileId, EntityIdentity newProfileId)?> RenameLaunchProfileAsync(IQueryExecutionContext queryExecutionContext, IEntityValue parent, string currentProfileName, string newProfileName, CancellationToken cancellationToken = default)
        {
            cancellationToken.ThrowIfCancellationRequested();

            ILaunchSettings launchSettings = await _launchSettingsProvider.WaitForFirstSnapshot(cancellationToken);

            ProjectSystem.Debug.ILaunchProfile?existingProfile = launchSettings.Profiles.FirstOrDefault(p => StringComparers.LaunchProfileNames.Equals(p.Name, currentProfileName));
            if (existingProfile is not null)
            {
                var writableProfile = new WritableLaunchProfile(existingProfile);
                writableProfile.Name = newProfileName;

                await _launchSettingsProvider.RemoveProfileAsync(currentProfileName);

                await _launchSettingsProvider.AddOrUpdateProfileAsync(writableProfile.ToLaunchProfile(), addToFront : false);

                if (_launchSettingsProvider.CurrentSnapshot is IVersionedLaunchSettings versionedLaunchSettings)
                {
                    queryExecutionContext.ReportUpdatedDataVersion(_launchSettingsTracker.VersionKey, versionedLaunchSettings.Version);
                }

                return(CreateLaunchProfileId(parent, currentProfileName), CreateLaunchProfileId(parent, newProfileName));
            }

            return(null);
        }
Esempio n. 6
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 <ILaunchProfile?> DuplicateLaunchProfileAsync(string currentProfileName, string?newProfileName, string?newProfileCommandName, CancellationToken cancellationToken = default)
        {
            cancellationToken.ThrowIfCancellationRequested();

            ILaunchSettings?launchSettings = await _launchSettingsProvider.WaitForFirstSnapshot(Timeout.Infinite).WithCancellation(cancellationToken);

            Assumes.NotNull(launchSettings);

            ILaunchProfile?existingProfile = launchSettings.Profiles.FirstOrDefault(p => StringComparers.LaunchProfileNames.Equals(p.Name, currentProfileName));

            if (existingProfile is not null)
            {
                newProfileName ??= await GetNewProfileNameAsync(cancellationToken);

                newProfileCommandName ??= existingProfile.CommandName;

                var writableProfile = new WritableLaunchProfile(existingProfile);
                writableProfile.Name        = newProfileName;
                writableProfile.CommandName = newProfileCommandName;

                await _launchSettingsProvider.AddOrUpdateProfileAsync(writableProfile.ToLaunchProfile(), addToFront : false);

                return(_launchSettingsProvider.CurrentSnapshot?.Profiles.FirstOrDefault(p => StringComparers.LaunchProfileNames.Equals(newProfileName, p.Name)));
            }

            return(null);
        }
Esempio n. 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"]);
        }
Esempio n. 9
0
        public void WebView2Debugging_OnGetPropertyValueAsync_GetsDefaultValueWhenNotDefined()
        {
            var profile = new WritableLaunchProfile().ToLaunchProfile();

            var provider = new ProjectLaunchProfileExtensionValueProvider();

            var actualValue = provider.OnGetPropertyValue(ProjectLaunchProfileExtensionValueProvider.WebView2DebuggingPropertyName, profile, EmptyGlobalSettings, rule: null);

            Assert.Equal(expected: "false", actual: actualValue);
        }
        public void IsInMemoryProfile_IWritableLaunchProfile(bool isInMemory)
        {
            var data = new WritableLaunchProfile()
            {
                DoNotPersist = isInMemory
            };

            var lp = (IWritableLaunchProfile)data;

            Assert.Equal(isInMemory, lp.IsInMemoryObject());
        }
Esempio n. 11
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);
        }
        internal void CreateProfile(string name, string commandName)
        {
            var profile = new WritableLaunchProfile {
                Name = name, CommandName = commandName
            };

            CurrentLaunchSettings.Profiles.Add(profile);
            LaunchProfiles.Add(profile);

            NotifyProfileCollectionChanged();

            // Fire a property changed so we can get the page to be dirty when we add a new profile
            OnPropertyChanged("_NewProfile");
            SelectedDebugProfile = profile;
        }
Esempio n. 13
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);
        }
Esempio n. 14
0
        public void HotReloadEnabled_OnGetPropertyValueAsync_GetsValueInProfileWhenDefined()
        {
            bool hotReloadEnabled = false;
            var  profile          = new WritableLaunchProfile
            {
                OtherSettings =
                {
                    { LaunchProfileExtensions.HotReloadEnabledProperty, hotReloadEnabled }
                }
            }.ToLaunchProfile();

            var provider = new ProjectLaunchProfileExtensionValueProvider();

            var actualValue = provider.OnGetPropertyValue(ProjectLaunchProfileExtensionValueProvider.HotReloadEnabledPropertyName, profile, EmptyGlobalSettings, rule: null);

            Assert.Equal(expected: "false", actual: actualValue);
        }
Esempio n. 15
0
        public void NativeDebugging_OnSetPropertyValueAsync_SetsNativeDebuggingInActiveProfile()
        {
            bool activeProfileNativeDebugging = false;
            var  profile = new WritableLaunchProfile
            {
                OtherSettings =
                {
                    { LaunchProfileExtensions.NativeDebuggingProperty, activeProfileNativeDebugging }
                }
            };

            var provider = new ProjectLaunchProfileExtensionValueProvider();

            provider.OnSetPropertyValue(ProjectLaunchProfileExtensionValueProvider.NativeDebuggingPropertyName, "true", profile, EmptyGlobalSettings, rule: null);

            Assert.True((bool)profile.OtherSettings[LaunchProfileExtensions.NativeDebuggingProperty]);
        }
Esempio n. 16
0
        public void RemoteDebugEnabled_OnGetPropertyValueAsync_GetsRemoteDebuggingFromActiveProfile()
        {
            bool activeProfileRemoteDebugEnabled = true;
            var  profile = new WritableLaunchProfile
            {
                OtherSettings =
                {
                    { LaunchProfileExtensions.RemoteDebugEnabledProperty, activeProfileRemoteDebugEnabled }
                }
            }.ToLaunchProfile();

            var provider = new ProjectLaunchProfileExtensionValueProvider();

            var actualValue = provider.OnGetPropertyValue(ProjectLaunchProfileExtensionValueProvider.RemoteDebugEnabledPropertyName, profile, EmptyGlobalSettings, rule: null);

            Assert.Equal(expected: "true", actual: actualValue);
        }
Esempio n. 17
0
        public void WebView2Debugging_OnSetPropertyValueAsync_SetsWebView2DebuggingToSpecifiedValue()
        {
            bool webView2Debugging = false;
            var  profile           = new WritableLaunchProfile
            {
                OtherSettings =
                {
                    { LaunchProfileExtensions.JSWebView2DebuggingProperty, webView2Debugging }
                }
            };

            var provider = new ProjectLaunchProfileExtensionValueProvider();

            provider.OnSetPropertyValue(ProjectLaunchProfileExtensionValueProvider.WebView2DebuggingPropertyName, "true", profile, EmptyGlobalSettings, rule: null);

            Assert.True((bool)profile.OtherSettings[LaunchProfileExtensions.JSWebView2DebuggingProperty]);
        }
Esempio n. 18
0
        public void AuthenticationMode_OnSetPropertyValueAsync_SetsModeInActiveProfile()
        {
            string activeProfileAuthenticationMode = "Windows";
            var    profile = new WritableLaunchProfile
            {
                OtherSettings =
                {
                    { LaunchProfileExtensions.RemoteAuthenticationModeProperty, activeProfileAuthenticationMode }
                }
            };

            var provider = new ProjectLaunchProfileExtensionValueProvider();

            provider.OnSetPropertyValue(ProjectLaunchProfileExtensionValueProvider.AuthenticationModePropertyName, "NotWindows", profile, EmptyGlobalSettings, rule: null);

            Assert.Equal(expected: "NotWindows", actual: profile.OtherSettings[LaunchProfileExtensions.RemoteAuthenticationModeProperty]);
        }
Esempio n. 19
0
        public void RemoteMachineName_OnGetPropertyValueAsync_GetsNameFromActiveProfile()
        {
            string activeProfileRemoteMachineName = "alphaMachine";
            var    profile = new WritableLaunchProfile
            {
                OtherSettings =
                {
                    { LaunchProfileExtensions.RemoteDebugMachineProperty, activeProfileRemoteMachineName }
                }
            }.ToLaunchProfile();

            var provider = new ProjectLaunchProfileExtensionValueProvider();

            var actualValue = provider.OnGetPropertyValue(ProjectLaunchProfileExtensionValueProvider.RemoteDebugMachinePropertyName, profile, EmptyGlobalSettings, rule: null);

            Assert.Equal(expected: activeProfileRemoteMachineName, actual: actualValue);
        }
Esempio n. 20
0
        public void WebView2Debugging_OnGetPropertyValueAsync_GetsValueInProfileWhenDefined()
        {
            bool webView2Debugging = true;
            var  profile           = new WritableLaunchProfile
            {
                OtherSettings =
                {
                    { LaunchProfileExtensions.JSWebView2DebuggingProperty, webView2Debugging }
                }
            }.ToLaunchProfile();

            var provider = new ProjectLaunchProfileExtensionValueProvider();

            var actualValue = provider.OnGetPropertyValue(ProjectLaunchProfileExtensionValueProvider.WebView2DebuggingPropertyName, profile, EmptyGlobalSettings, rule: null);

            Assert.Equal(expected: "true", actual: actualValue);
        }
Esempio n. 21
0
        public void HotReloadEnabled_OnSetPropertyValueAsync_SetsHotReloadToSpecifiedValue()
        {
            bool hotReloadEnabled = true;
            var  profile          = new WritableLaunchProfile
            {
                OtherSettings =
                {
                    { LaunchProfileExtensions.HotReloadEnabledProperty, hotReloadEnabled }
                }
            };

            var provider = new ProjectLaunchProfileExtensionValueProvider();

            provider.OnSetPropertyValue(ProjectLaunchProfileExtensionValueProvider.HotReloadEnabledPropertyName, "false", profile, EmptyGlobalSettings, rule: null);

            Assert.False((bool)profile.OtherSettings[LaunchProfileExtensions.HotReloadEnabledProperty]);
        }
Esempio n. 22
0
        public void RemoteMachineName_OnSetPropertyValueAsync_SetsNameInActiveProfile()
        {
            string activeProfileRemoteMachineName = "Tiger";
            var    profile = new WritableLaunchProfile
            {
                OtherSettings =
                {
                    { LaunchProfileExtensions.RemoteDebugMachineProperty, activeProfileRemoteMachineName }
                }
            };

            var provider = new ProjectLaunchProfileExtensionValueProvider();

            provider.OnSetPropertyValue(ProjectLaunchProfileExtensionValueProvider.RemoteDebugMachinePropertyName, "Cheetah", profile, EmptyGlobalSettings, rule: null);

            Assert.Equal(expected: "Cheetah", actual: profile.OtherSettings[LaunchProfileExtensions.RemoteDebugMachineProperty]);
        }
Esempio n. 23
0
        public void AuthenticationMode_OnGetPropertyValueAsync_GetsModeFromActiveProfile()
        {
            string activeProfileAuthenticationMode = "Windows";
            var    profile = new WritableLaunchProfile
            {
                OtherSettings =
                {
                    { LaunchProfileExtensions.RemoteAuthenticationModeProperty, activeProfileAuthenticationMode }
                }
            }.ToLaunchProfile();

            var provider = new ProjectLaunchProfileExtensionValueProvider();

            var actualValue = provider.OnGetPropertyValue(ProjectLaunchProfileExtensionValueProvider.AuthenticationModePropertyName, profile, EmptyGlobalSettings, rule: null);

            Assert.Equal(expected: activeProfileAuthenticationMode, actual: actualValue);
        }
        protected override async Task ExecuteAsync(ILaunchSettingsProvider launchSettingsProvider, CancellationToken cancellationToken)
        {
            ILaunchSettings?launchSettings = await launchSettingsProvider.WaitForFirstSnapshot(Timeout.Infinite).WithCancellation(cancellationToken);

            Assumes.NotNull(launchSettings);

            ILaunchProfile?existingProfile = launchSettings.Profiles.FirstOrDefault(p => StringComparers.LaunchProfileNames.Equals(p.Name, _executableStep.CurrentProfileName));

            if (existingProfile is not null)
            {
                var writableProfile = new WritableLaunchProfile(existingProfile);
                writableProfile.Name        = _executableStep.NewProfileName;
                writableProfile.CommandName = _executableStep.NewProfileCommandName;

                await launchSettingsProvider.AddOrUpdateProfileAsync(writableProfile.ToLaunchProfile(), addToFront : false);
            }
        }
Esempio n. 25
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);
        }
Esempio n. 26
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);
            }
        }
Esempio n. 27
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);
        }
Esempio n. 28
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);
        }
Esempio n. 29
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);
            }
        }
Esempio n. 30
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);
        }