Пример #1
0
        public void TestRemoveAccessPoints()
        {
            var capabilityList = CapabilityListTest.CreateTestCapabilityList();
            var testApp        = new Feed {
                Name = "Test", CapabilityLists = { capabilityList }
            };

            using (var unapplyFlag = new TemporaryFlagFile("0install-unit-tests"))
            {
                var accessPoint = new MockAccessPoint {
                    ID = "id1", Capability = "my_ext1", UnapplyFlagPath = unapplyFlag
                };

                // Inject access point into AppEntry (without running integration)
                var appEntry = _integrationManager.AddApp(new FeedTarget(FeedTest.Test1Uri, testApp));
                appEntry.AccessPoints = new AccessPointList {
                    Entries = { accessPoint }
                };

                _integrationManager.RemoveAccessPoints(appEntry, new[] { accessPoint });
                Assert.IsEmpty(_integrationManager.AppList.Entries[0].AccessPoints.Entries);

                Assert.IsTrue(unapplyFlag.Set, "Unapply() should be called");

                Assert.DoesNotThrow(() => _integrationManager.RemoveAccessPoints(appEntry, new[] { accessPoint }), "Allow multiple removals of access points.");
            }
        }
Пример #2
0
        /// <summary>
        /// Resolves or removes existing aliases.
        /// </summary>
        /// <param name="aliasName">The name of the existing alias.</param>
        /// <returns>The exit status code to end the process with.</returns>
        private ExitCode ResolveOrRemove(string aliasName)
        {
            using (var integrationManager = new IntegrationManager(Handler, MachineWide))
            {
                AppEntry appEntry;
                var appAlias = GetAppAlias(integrationManager.AppList, aliasName, out appEntry);
                if (appAlias == null)
                {
                    Handler.Output(Resources.AppAlias, string.Format(Resources.AliasNotFound, aliasName));
                    return ExitCode.InvalidArguments;
                }

                if (_resolve)
                {
                    string result = appEntry.InterfaceUri.ToStringRfc();
                    if (!string.IsNullOrEmpty(appAlias.Command)) result += Environment.NewLine + "Command: " + appAlias.Command;
                    Handler.OutputLow(Resources.AppAlias, result);
                }
                if (_remove)
                {
                    integrationManager.RemoveAccessPoints(appEntry, new AccessPoint[] {appAlias});

                    Handler.OutputLow(Resources.AppAlias, string.Format(Resources.AliasRemoved, aliasName, appEntry.Name));
                }
                return ExitCode.OK;
            }
        }