public static void AssertVersionsEqual(
            ulong expectedMajor,
            ulong expectedMinor,
            ulong expectedPatch,
            string expectedPreRelease,
            string expectedBuildMetadata,
            SemverVersion actual) {
            Assert.AreEqual(expectedMajor, actual.Major);
            Assert.AreEqual(expectedMinor, actual.Minor, "Mismatched minor version.");
            Assert.AreEqual(expectedPatch, actual.Patch, "Mismatched patch version.");
            Assert.AreEqual(
                null != expectedPreRelease,
                actual.HasPreReleaseVersion,
                "Pre-release version info presence mismatch.");
            Assert.AreEqual(expectedPreRelease, actual.PreReleaseVersion, "Pre-release version info mismatch.");
            Assert.AreEqual(null != expectedBuildMetadata, actual.HasBuildMetadata, "Build metadata presence mismatch.");
            Assert.AreEqual(expectedBuildMetadata, actual.BuildMetadata, "Build metadata mismatch.");

            var expected = new StringBuilder(string.Format(CultureInfo.InvariantCulture, "{0}.{1}.{2}", expectedMajor, expectedMinor, expectedPatch));
            if (null != expectedPreRelease) {
                expected.Append('-');
                expected.Append(expectedPreRelease);
            }

            if (null != expectedBuildMetadata) {
                expected.Append('+');
                expected.Append(expectedBuildMetadata);
            }

            Assert.AreEqual(expected.ToString(), actual.ToString());
        }
 protected PackageCatalogEntryViewModel(
     string name,
     SemverVersion? version,
     IEnumerable<SemverVersion> availableVersions, 
     string author,
     string description,
     IEnumerable<string> homepages,
     string keywords,
     SemverVersion? localVersion
 ) {
     _name = name;
     _version = version;
     _availableVersions = availableVersions != null ? availableVersions.ToList() : new List<SemverVersion>();
     _author = author;
     _description = description;
     _homepages = homepages != null ? homepages.ToList() : new List<string>();
     _keywords = keywords;
     _localVersion = localVersion;
 }
Ejemplo n.º 3
0
        private void CheckPackage(
            IList<IPackage> packages,
            IDictionary<string, IPackage> packagesByName,
            int expectedIndex,
            string expectedName,
            string expectedDescription,
            string expectedAuthor,
            string expectedPublishDateTime,
            SemverVersion expectedVersion,
            IEnumerable<SemverVersion> expectedVersions,
            IEnumerable<string> expectedKeywords) {
            CheckPackage(
                packagesByName[expectedName],
                expectedName,
                expectedDescription,
                expectedAuthor,
                expectedPublishDateTime,
                expectedVersion,
                expectedVersions,
                expectedKeywords);

            if (expectedIndex >= 0) {
                for (int index = 0, size = packages.Count; index < size; ++index ) {
                    if (packages[index].Name == expectedName) {
                        Assert.AreEqual(
                            expectedIndex,
                            index,
                            string.Format("Package '{0}' not at expected index in list.", expectedName));
                    }
                }

                CheckPackage(
                    packages[expectedIndex],
                    expectedName,
                    expectedDescription,
                    expectedAuthor,
                    expectedPublishDateTime,
                    expectedVersion,
                    expectedVersions,
                    expectedKeywords);
            }
        }
Ejemplo n.º 4
0
        private void CheckPackage(
            IPackage package,
            string expectedName,
            string expectedDescription,
            string expectedAuthor,
            string expectedPublishDateTime,
            SemverVersion expectedVersion,
            IEnumerable<SemverVersion> expectedVersions,
            IEnumerable<string> expectedKeywords) {

            Assert.AreEqual(expectedName, package.Name, "Invalid name.");
            Assert.AreEqual(expectedDescription, package.Description, "Invalid description.");
            string actualAuthorString = null == package.Author ? null : package.Author.Name;
            Assert.AreEqual(expectedAuthor, actualAuthorString, "Invalid author.");
            Assert.AreEqual(expectedPublishDateTime, package.PublishDateTimeString, "Invalid publish date/time.");
            Assert.AreEqual(expectedVersion, package.Version, "Invalid version.");

            // Sometimes authors include duplicate keywords in the list
            AssertUtil.ArrayEquals(package.Keywords.Distinct().ToList(), expectedKeywords.Distinct().ToList());
            AssertUtil.ArrayEquals(package.AvailableVersions.ToList(), expectedVersions.ToList());
        }
 private static string ToString(SemverVersion? version) {
     return version.HasValue ? version.ToString() : string.Empty;
 }
Ejemplo n.º 6
0
 public void AddVersion(SemverVersion version)
 {
     this.AvailableVersions.Add(version);
 }