コード例 #1
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 LaunchProfilesProjectItemProvider(
                UnconfiguredProjectFactory.Create(),
                launchSettingsProvider);

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

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

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

            Assert.Collection(items,
                              item => Assert.Equal("Profile2", item.EvaluatedInclude));
        }
コード例 #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 LaunchProfilesProjectItemProvider(
                UnconfiguredProjectFactory.Create(),
                launchSettingsProvider);

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

            var item = await itemProvider.GetItemAsync(context);

            Assert.NotNull(item);
            Assert.Equal("Profile2", item !.EvaluatedInclude);
        }
コード例 #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 LaunchProfilesProjectItemProvider(
                UnconfiguredProjectFactory.Create(),
                launchSettingsProvider);

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

            var item = await itemProvider.GetItemAsync(context);

            Assert.Null(item);
        }
コード例 #4
0
        public void IsInMemoryProfile_IWritableLaunchProfile(bool isInMemory)
        {
            var data = new WritableLaunchProfile()
            {
                DoNotPersist = isInMemory
            };

            var lp = (IWritableLaunchProfile)data;

            Assert.Equal(isInMemory, lp.IsInMemoryObject());
        }
コード例 #5
0
        public async Task WhenThereAreLaunchProfiles_GetExistingItemTypesAsyncReturnsASingleItem()
        {
            var profile = new WritableLaunchProfile {
                Name = "Test"
            };
            var launchSettingsProvider = ILaunchSettingsProviderFactory.Create(
                launchProfiles: new[] { profile.ToLaunchProfile() });

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

            var existingItemTypes = await itemProvider.GetExistingItemTypesAsync();

            Assert.Single(existingItemTypes, LaunchProfilesProjectItemProvider.ItemType);
        }
コード例 #6
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 LaunchProfilesProjectItemProvider(
                UnconfiguredProjectFactory.Create(),
                launchSettingsProvider);

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

            Assert.Null(item);
        }
コード例 #7
0
        public static bool SetttingsDiffer(this IWritableLaunchSettings launchSettings, IWritableLaunchSettings settingsToCompare)
        {
            if (launchSettings.Profiles.Count != settingsToCompare.Profiles.Count)
            {
                return(true);
            }

            // Now compare each item. We can compare in order. If the lists are different then the settings are different even
            // if they contain the same items
            for (int i = 0; i < launchSettings.Profiles.Count; i++)
            {
                if (!WritableLaunchProfile.ProfilesAreEqual(launchSettings.Profiles[i], settingsToCompare.Profiles[i]))
                {
                    return(true);
                }
            }

            // Check the global settings
            return(DictionaryEqualityComparer <string, object> .Instance.Equals(launchSettings.GlobalSettings.ToImmutableDictionary(), settingsToCompare.GlobalSettings.ToImmutableDictionary()));
        }
コード例 #8
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 LaunchProfilesProjectItemProvider(
                UnconfiguredProjectFactory.Create(),
                launchSettingsProvider);

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

            Assert.NotNull(item);
            Assert.Equal(expected: "Profile2", actual: item !.EvaluatedInclude);
        }
コード例 #9
0
        public async Task WhenAskedForOtherItemTypes_GetItemsAsyncReturnsAnEmptyEnumerable()
        {
            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 LaunchProfilesProjectItemProvider(
                UnconfiguredProjectFactory.Create(),
                launchSettingsProvider);

            var items = await itemProvider.GetItemsAsync("RandomItemType");

            Assert.Empty(items);

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

            Assert.Empty(items);
        }
コード例 #10
0
        public async Task WhenGivenMultipleProjectPropertyContexts_GetItemsAsyncReturnsNullOrAnItemForEach()
        {
            var profile1 = new WritableLaunchProfile {
                Name = "Profile1"
            };
            var profile2 = new WritableLaunchProfile {
                Name = "Profile2"
            };
            var profile3 = new WritableLaunchProfile {
                Name = "Profile3"
            };
            var launchSettingsProvider = ILaunchSettingsProviderFactory.Create(
                launchProfiles: new[]
            {
                profile1.ToLaunchProfile(),
                profile2.ToLaunchProfile(),
                profile3.ToLaunchProfile()
            });

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

            List <IProjectPropertiesContext> contexts = new()
            {
                new TestProjectPropertiesContext(true, "Foo", null, "Profile3"),
                new TestProjectPropertiesContext(true, "Foo", "RandomItemType", "Profile2"),
                new TestProjectPropertiesContext(true, "Foo", LaunchProfilesProjectItemProvider.ItemType, "Profile1")
            };

            var items = await itemProvider.GetItemsAsync(contexts);

            Assert.Collection(items,
                              item => Assert.Equal("Profile3", item !.EvaluatedInclude),
                              item => Assert.Null(item),
                              item => Assert.Equal("Profile1", item !.EvaluatedInclude));
        }