public async Task WaitsForPackageAvailabilityInGalleryDBWithCheckValidator()
        {
            var messageData             = PackageValidationMessageData.NewCheckValidator(Guid.NewGuid());
            var validationConfiguration = new ValidationConfiguration();
            var validationSet           = new PackageValidationSet {
                PackageKey = 42, ValidatingType = ValidatingType.SymbolPackage
            };

            ValidationSetProviderMock
            .Setup(ps => ps.TryGetParentValidationSetAsync(messageData.CheckValidator.ValidationId))
            .ReturnsAsync(validationSet)
            .Verifiable();
            CoreSymbolPackageServiceMock
            .Setup(ps => ps.FindPackageByKey(validationSet.PackageKey))
            .Returns <SymbolPackage>(null)
            .Verifiable();

            var handler = CreateHandler();

            var result = await handler.HandleAsync(messageData);

            ValidationSetProviderMock.Verify(
                ps => ps.TryGetParentValidationSetAsync(messageData.CheckValidator.ValidationId),
                Times.Once);
            CoreSymbolPackageServiceMock.Verify(
                ps => ps.FindPackageByKey(validationSet.PackageKey),
                Times.Once);

            Assert.False(result, "The handler should not have succeeded.");
        }
        public async Task DropsMessageAfterMissingPackageRetryCountIsReached()
        {
            var validationTrackingId = Guid.NewGuid();
            var messageData          = PackageValidationMessageData.NewProcessValidationSet(
                "packageId",
                "1.2.3",
                validationTrackingId,
                ValidatingType.SymbolPackage,
                entityKey: null);

            CoreSymbolPackageServiceMock
            .Setup(ps => ps.FindPackageByIdAndVersionStrict("packageId", "1.2.3"))
            .Returns <SymbolPackage>(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)));

            CoreSymbolPackageServiceMock.Verify(ps => ps.FindPackageByIdAndVersionStrict("packageId", "1.2.3"), Times.Exactly(3));
            TelemetryServiceMock.Verify(t => t.TrackMissingPackageForValidationMessage("packageId", "1.2.3", validationTrackingId.ToString()), Times.Once);
        }
示例#3
0
        public async Task DropsMessageOnDuplicateValidationRequest()
        {
            var messageData             = new PackageValidationMessageData("packageId", "1.2.3", Guid.NewGuid(), ValidatingType.SymbolPackage);
            var validationConfiguration = new ValidationConfiguration();
            var symbolPackage           = new SymbolPackage()
            {
                Package = new Package()
            };
            var symbolPackageValidatingEntity = new SymbolPackageValidatingEntity(symbolPackage);

            CoreSymbolPackageServiceMock
            .Setup(ps => ps.FindPackageByIdAndVersionStrict(messageData.PackageId, messageData.PackageVersion))
            .Returns(symbolPackageValidatingEntity)
            .Verifiable();

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

            var handler = CreateHandler();

            var result = await handler.HandleAsync(messageData);

            Assert.True(result);
            CoreSymbolPackageServiceMock
            .Verify(ps => ps.FindPackageByIdAndVersionStrict(messageData.PackageId, messageData.PackageVersion), Times.Once());
            ValidationSetProviderMock
            .Verify(vsp => vsp.TryGetOrCreateValidationSetAsync(messageData, symbolPackageValidatingEntity), Times.Once());
        }
示例#4
0
        public async Task WaitsForPackageAvailabilityInGalleryDB()
        {
            var messageData             = new PackageValidationMessageData("packageId", "1.2.3", Guid.NewGuid(), ValidatingType.SymbolPackage);
            var validationConfiguration = new ValidationConfiguration();

            CoreSymbolPackageServiceMock
            .Setup(ps => ps.FindPackageByIdAndVersionStrict(messageData.PackageId, messageData.PackageVersion))
            .Returns <SymbolPackage>(null)
            .Verifiable();

            var handler = CreateHandler();

            await handler.HandleAsync(messageData);

            CoreSymbolPackageServiceMock.Verify(ps => ps.FindPackageByIdAndVersionStrict(messageData.PackageId, messageData.PackageVersion), Times.Once());
        }
示例#5
0
        public SymbolValidationMessageHandlerLooseFacts()
            : base(MockBehavior.Loose)
        {
            SymbolPackage = new SymbolPackage()
            {
                Package = new Package()
            };
            MessageData   = new PackageValidationMessageData("packageId", "1.2.3", Guid.NewGuid(), ValidatingType.SymbolPackage);
            ValidationSet = new PackageValidationSet();
            SymbolPackageValidatingEntity = new SymbolPackageValidatingEntity(SymbolPackage);

            CoreSymbolPackageServiceMock
            .Setup(ps => ps.FindPackageByIdAndVersionStrict(MessageData.PackageId, MessageData.PackageVersion))
            .Returns(SymbolPackageValidatingEntity);

            ValidationSetProviderMock
            .Setup(vsp => vsp.TryGetOrCreateValidationSetAsync(MessageData, SymbolPackageValidatingEntity))
            .ReturnsAsync(ValidationSet);
        }