public void IdExceedingMaxLengthThrows(int idTestLength)
        {
            // Arrange
            string packageId = new string('d', idTestLength);

            // Act && Assert
            ExceptionAssert.ThrowsArgumentException(
                () => PackageIdValidator.ValidatePackageId(packageId),
                "Id must not exceed 100 characters.");
        }
Beispiel #2
0
        public void PackageBuilderThrowsIfPackageIdInvalid()
        {
            // Arrange
            var builder = new PackageBuilder {
                Id          = "  a.  b",
                Version     = new Version("1.0"),
                Description = "Description"
            };

            builder.Authors.Add("Me");

            // Act & Assert
            ExceptionAssert.ThrowsArgumentException(() => builder.Save(new MemoryStream()), "Package id '  a.  b' is invalid.");
        }
 public void ParseThrowsIfStringIsNotAValidSemVer(string versionString)
 {
     ExceptionAssert.ThrowsArgumentException(() => SemanticVersion.Parse(versionString),
                                             "version",
                                             String.Format(CultureInfo.InvariantCulture, "'{0}' is not a valid version string.", versionString));
 }
Beispiel #4
0
 public void CryptoHashProviderThrowsIfHashAlgorithmIsNotSHA512orSHA256(string hashAlgorithm)
 {
     // Act and Assert
     ExceptionAssert.ThrowsArgumentException(() => new CryptoHashProvider(hashAlgorithm), "hashAlgorithm",
                                             String.Format("Hash algorithm '{0}' is unsupported. Supported algorithms include: SHA512 and SHA256.", hashAlgorithm));
 }