コード例 #1
0
            public async Task AlwaysUsesValidationSetPackageWhenHasAnyProcessor()
            {
                ValidationSet.PackageValidations = new List <PackageValidation>
                {
                    new PackageValidation {
                        Type = "SomeValidatorA"
                    },
                    new PackageValidation {
                        Type = "SomeValidatorB"
                    },
                    new PackageValidation {
                        Type = "SomeProcessorA"
                    },
                    new PackageValidation {
                        Type = "SomeProcessorB"
                    },
                };
                var expected = new StorageException("Validation set package not found!");

                ValidatorProviderMock
                .Setup(x => x.IsNuGetProcessor(It.Is <string>(n => n.Contains("Processor"))))
                .Returns(true);
                PackageFileServiceMock
                .Setup(x => x.CopyValidationSetPackageToPackageFileAsync(ValidationSet, It.IsAny <IAccessCondition>()))
                .Throws(expected);

                var actual = await Assert.ThrowsAsync <StorageException>(
                    () => Target.SetStatusAsync(PackageValidatingEntity, ValidationSet, PackageStatus.Available));

                Assert.Same(expected, actual);

                PackageFileServiceMock.Verify(
                    x => x.UpdatePackageBlobMetadataInValidationSetAsync(It.IsAny <PackageValidationSet>()),
                    Times.Once);
                PackageFileServiceMock.Verify(
                    x => x.UpdatePackageBlobMetadataInValidationAsync(It.IsAny <PackageValidationSet>()),
                    Times.Never);
                PackageFileServiceMock.Verify(
                    x => x.CopyValidationPackageToPackageFileAsync(It.IsAny <PackageValidationSet>()),
                    Times.Never);
                PackageFileServiceMock.Verify(
                    x => x.DoesValidationSetPackageExistAsync(It.IsAny <PackageValidationSet>()),
                    Times.Never);
                ValidatorProviderMock.Verify(
                    x => x.IsNuGetProcessor("SomeValidatorA"),
                    Times.Once);
                ValidatorProviderMock.Verify(
                    x => x.IsNuGetProcessor("SomeValidatorB"),
                    Times.Once);
                ValidatorProviderMock.Verify(
                    x => x.IsNuGetProcessor("SomeProcessorA"),
                    Times.Once);
                ValidatorProviderMock.Verify(
                    x => x.IsNuGetProcessor("SomeProcessorB"),
                    Times.Never); // Never checked, since SomeProcessorA was found.
            }
コード例 #2
0
 protected void UseDefaultValidatorProvider()
 {
     ValidatorProviderMock
     .Setup(vp => vp.GetValidator(It.IsAny <string>()))
     .Returns <string>(name => Validators[name].Object);
 }