Beispiel #1
0
        /// <summary>
        /// Verifies if a set of packages in the feed have timestamps in a particular order.
        /// </summary>
        /// <param name="packageIds">An ordered list of package ids. Each package id in the list must have a timestamp in the feed earlier than all package ids after it.</param>
        /// <param name="timestampPropertyName">The timestamp property to test the ordering of. For example, "Created" or "LastEdited".</param>
        /// <param name="operationStartTimestamp">A timestamp that is before all of the timestamps expected to be found in the feed. This is used in a request to the feed.</param>
        /// <param name="packagesListed">Whether packages are listed, used to verify if latest flags are set properly.</param>
        private async Task CheckPackageTimestampsInOrder(List <string> packageIds, string timestampPropertyName,
                                                         DateTime operationStartTimestamp)
        {
            var lastTimestamp = DateTime.MinValue;

            for (var i = 0; i < PackagesInOrderNumPackages; i++)
            {
                var packageId = packageIds[i];
                TestOutputHelper.WriteLine($"Attempting to check order of package #{i} {timestampPropertyName} timestamp in feed.");

                var feedUrl        = GetPackagesAppearInFeedInOrderUrl(operationStartTimestamp, timestampPropertyName);
                var packageDetails = await _odataHelper.GetPackagePropertiesFromResponse(feedUrl, packageId);

                Assert.NotNull(packageDetails);

                var newTimestamp = (DateTime?)(packageDetails.ContainsKey(timestampPropertyName)
                    ? packageDetails[timestampPropertyName]
                    : null);

                Assert.True(newTimestamp.HasValue);
                Assert.True(newTimestamp.Value > lastTimestamp,
                            $"Package #{i} was last modified after package #{i - 1} but has an earlier {timestampPropertyName} timestamp ({newTimestamp} should be greater than {lastTimestamp}).");
                lastTimestamp = newTimestamp.Value;

                var published      = packageDetails["Published"] as DateTime?;
                var isListed       = !published?.Year.Equals(1900);
                var isLatest       = packageDetails["IsAbsoluteLatestVersion"] as bool?;
                var isLatestStable = packageDetails["IsLatestVersion"] as bool?;

                Assert.NotNull(isLatest);
                Assert.Equal(isLatest, isListed);

                Assert.NotNull(isLatestStable);
                Assert.Equal(isLatestStable, isListed);
            }
        }