예제 #1
0
        /// <inheritdoc />
        public void Update(IRepositoryInstalled repository, IPackage initial, IPackage target)
        {
            if (!repository.HasPackage(initial))
            {
                throw new InvalidArgumentException($"Package is not installed: {initial}");
            }

            var name       = target.GetName();
            var from       = initial.GetVersionPrettyFull();
            var to         = target.GetVersionPrettyFull();
            var actionName = VersionParser.IsUpgrade(initial.GetVersion(), target.GetVersion()) ? "Updating" : "Downgrading";

            io.WriteError($"  - {actionName} <info>{name}</info> (<comment>{from}</comment> => <comment>{to}</comment>)");

            repository.RemovePackage(initial);
            repository.AddPackage((IPackage)target.Clone());
        }
예제 #2
0
 public void TestIsUpgrade(bool expected, string from, string to)
 {
     Assert.AreEqual(expected, VersionParser.IsUpgrade(from, to));
 }