コード例 #1
0
        public async Task DropsMessageOnDuplicateValidationRequest()
        {
            var messageData = PackageValidationMessageData.NewProcessValidationSet(
                "packageId",
                "1.2.3",
                Guid.NewGuid(),
                ValidatingType.Package,
                entityKey: null);
            var validationConfiguration = new ValidationConfiguration();
            var package = new Package();
            var packageValidatingEntity = new PackageValidatingEntity(package);

            CorePackageServiceMock
            .Setup(ps => ps.FindPackageByIdAndVersionStrict(
                       messageData.ProcessValidationSet.PackageId,
                       messageData.ProcessValidationSet.PackageVersion))
            .Returns(packageValidatingEntity)
            .Verifiable();

            ValidationSetProviderMock
            .Setup(vsp => vsp.TryGetOrCreateValidationSetAsync(
                       messageData.ProcessValidationSet,
                       packageValidatingEntity))
            .ReturnsAsync((PackageValidationSet)null)
            .Verifiable();

            var handler = CreateHandler();

            var result = await handler.HandleAsync(messageData);

            Assert.True(result);
            CorePackageServiceMock.Verify(
                ps => ps.FindPackageByIdAndVersionStrict(
                    messageData.ProcessValidationSet.PackageId,
                    messageData.ProcessValidationSet.PackageVersion),
                Times.Once);
            ValidationSetProviderMock.Verify(
                vsp => vsp.TryGetOrCreateValidationSetAsync(
                    messageData.ProcessValidationSet,
                    packageValidatingEntity),
                Times.Once);
        }
コード例 #2
0
        public async Task DropsMessageIfPackageIsSoftDeleted()
        {
            var messageData             = new PackageValidationMessageData("packageId", "1.2.3", Guid.NewGuid());
            var validationConfiguration = new ValidationConfiguration();
            var package = new Package {
                PackageStatusKey = PackageStatus.Deleted
            };

            CorePackageServiceMock
            .Setup(ps => ps.FindPackageByIdAndVersionStrict(messageData.PackageId, messageData.PackageVersion))
            .Returns(package);

            var handler = CreateHandler();

            var result = await handler.HandleAsync(messageData);

            Assert.True(result);
            CorePackageServiceMock
            .Verify(ps => ps.FindPackageByIdAndVersionStrict(messageData.PackageId, messageData.PackageVersion), Times.Once);
        }
コード例 #3
0
        public async Task DropsMessageAfterMissingPackageRetryCountIsReached()
        {
            var validationTrackingId = Guid.NewGuid();
            var messageData          = new PackageValidationMessageData("packageId", "1.2.3", validationTrackingId);

            CorePackageServiceMock
            .Setup(ps => ps.FindPackageByIdAndVersionStrict("packageId", "1.2.3"))
            .Returns <Package>(null)
            .Verifiable();

            TelemetryServiceMock
            .Setup(t => t.TrackMissingPackageForValidationMessage("packageId", "1.2.3", validationTrackingId.ToString()))
            .Verifiable();

            var handler = CreateHandler();

            Assert.False(await handler.HandleAsync(OverrideDeliveryCount(messageData, deliveryCount: 1)));
            Assert.False(await handler.HandleAsync(OverrideDeliveryCount(messageData, deliveryCount: 2)));
            Assert.True(await handler.HandleAsync(OverrideDeliveryCount(messageData, deliveryCount: 3)));

            CorePackageServiceMock.Verify(ps => ps.FindPackageByIdAndVersionStrict("packageId", "1.2.3"), Times.Exactly(3));
            TelemetryServiceMock.Verify(t => t.TrackMissingPackageForValidationMessage("packageId", "1.2.3", validationTrackingId.ToString()), Times.Once);
        }