Ejemplo n.º 1
0
 public void ShouldReturnTokensForValidPackageConstraint()
 {
     string[] stringsToTest = { "packageName:1", "packageName:1.02.4.0" };
     foreach (var s in stringsToTest)
     {
         var tokens = PackageConstraintExtensions.GetPackageIdAndVersion(s);
         Assert.IsTrue(tokens.Length == 2);
         Assert.IsFalse(string.IsNullOrWhiteSpace(tokens[0]));
         Assert.IsFalse(string.IsNullOrWhiteSpace(tokens[1]));
     }
 }
Ejemplo n.º 2
0
 public void ShouldThrowArgumentExceptionForInvalidPackageConstraint()
 {
     string[] stringsToTest = { "package name:1.0", "", " ", "packageName:1.0:2.0", "packageA:1.0;packageB:2.0" };
     foreach (var s in stringsToTest)
     {
         Assert.Throws <ArgumentException>(delegate
         {
             PackageConstraintExtensions.
             GetPackageIdAndVersion(s);
         });
     }
 }
Ejemplo n.º 3
0
        public void ParsePackageConstraint(string value)
        {
            try
            {
                var packageIdAndVersion = PackageConstraintExtensions.GetPackageIdAndVersion(value);

                if (PackageVersionNumberOverrides.ContainsKey(packageIdAndVersion[0]))
                {
                    throw new ArgumentException(string.Format("More than one constraint was specified for package {0}", packageIdAndVersion[0]));
                }

                PackageVersionNumberOverrides.Add(packageIdAndVersion[0], packageIdAndVersion[1]);
            }
            catch (ArgumentException ex)
            {
                throw new CommandException(ex.Message);
            }
        }