Example #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));
        }
Example #2
0
        public async Task WhenThereAreNoLaunchProfiles_GetItemsAsyncReturnsAnEmptyEnumerable()
        {
            var launchSettingsProvider = ILaunchSettingsProviderFactory.Create(
                launchProfiles: new LaunchProfile[0]);

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

            var items = await itemProvider.GetItemsAsync();

            Assert.Empty(items);
        }
Example #3
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);
        }
Example #4
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));
        }