/// <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>
        private async Task CheckPackageTimestampsInOrder(
            IEnumerable <string> packageIds,
            string timestampPropertyName,
            DateTime operationStartTimestamp,
            string version)
        {
            var lastTimestamp = DateTime.MinValue;
            var lastPackageId = string.Empty;

            foreach (var packageId in packageIds)
            {
                TestOutputHelper.WriteLine($"Attempting to check order of package {packageId} {version} {timestampPropertyName} timestamp in feed.");

                var newTimestamp = await _odataHelper.GetTimestampOfPackageFromResponse(
                    packageId,
                    version,
                    timestampPropertyName);

                Assert.True(newTimestamp.HasValue);
                Assert.True(newTimestamp.Value >= lastTimestamp,
                            $"Package {packageId} was last modified after package {lastPackageId} but has an earlier {timestampPropertyName} timestamp ({newTimestamp} should be greater than {lastTimestamp}).");
                lastTimestamp = newTimestamp.Value;
                lastPackageId = packageId;
            }
        }
Esempio n. 2
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>
        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 newTimestamp =
                    await
                    _odataHelper.GetTimestampOfPackageFromResponse(
                        GetPackagesAppearInFeedInOrderUrl(operationStartTimestamp, timestampPropertyName),
                        timestampPropertyName,
                        packageId);

                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;
            }
        }