示例#1
0
        protected void ValidateTypeSelection(BundleType typeSelection)
        {
            var bundleTypes = Enum.GetValues(typeof(BundleType)).OfType <BundleType>();

            if ((int)typeSelection < 1 || typeSelection > bundleTypes.Aggregate((BundleType)0, (orSum, next) => orSum | next))
            {
                throw new ArgumentOutOfRangeException();
            }

            if (!bundleTypes.Contains(typeSelection))
            {
                throw new BundleTypeMissingException(SupportedBundleTypeConfigs
                                                     .GetSupportedBundleTypes()
                                                     .OrderBy(type => type.OptionName)
                                                     .Select(type => $"--{type.OptionName}"));
            }
        }
示例#2
0
        private void ListCommandFilteringIsCorrect(string bundleType, string options, string[] expectedProtected, string[] expectedUninstallable)
        {
            var bundles = new List <Bundle>();

            foreach (var pair in versionsWithArch)
            {
                bundles.Add(new Bundle <SdkVersion>(new SdkVersion(pair.Key), pair.Value, "sdk", pair.Key));
                bundles.Add(new Bundle <RuntimeVersion>(new RuntimeVersion(pair.Key), pair.Value, "runtime", pair.Key));
            }
            var parseResult = CommandLineConfigs.UninstallRootCommand.Parse($"list --{ bundleType } { options }");
            var result      = ListCommandExec.GetFilteredBundlesWithRequirements(bundles, SupportedBundleTypeConfigs.GetSupportedBundleTypes(), parseResult);

            result.Values.Count().Should().Be(1);
            var bundleResults = result.FirstOrDefault();

            bundleResults.Key.Type.Should().Be(bundleType.Equals("sdk") ? BundleType.Sdk : BundleType.Runtime);
            bundleResults.Should().NotBeNull();

            bundleResults.Value.Where(pair => pair.Value.Equals(string.Empty)).Select(pair => pair.Key.DisplayName)
            .Should().BeEquivalentTo(expectedUninstallable);
            bundleResults.Value.Where(pair => !pair.Value.Equals(string.Empty)).Select(pair => pair.Key.DisplayName)
            .Should().BeEquivalentTo(expectedProtected);
        }