public async Task Skips( RegistrationLeafValidator validator, PackageRegistrationLeafMetadata v2, PackageRegistrationLeafMetadata v3) { Assert.Equal(false, await validator.ShouldRunLeafAsync(ValidatorTestUtility.GetFakeValidationContext(), v2, v3)); }
public async Task PassesIfEqual( RegistrationIndexValidator validator, PackageRegistrationIndexMetadata v2, PackageRegistrationIndexMetadata v3) { await validator.CompareIndexAsync(ValidatorTestUtility.GetFakeValidationContext(), v2, v3); }
public async Task Skips( RegistrationIndexValidator validator, PackageRegistrationIndexMetadata v2, PackageRegistrationIndexMetadata v3) { Assert.False(await validator.ShouldRunIndexAsync(ValidatorTestUtility.GetFakeValidationContext(), v2, v3)); }
protected PackageIsRepositorySignedValidator CreateTarget(bool requirePackageSignature = true) { var logger = Mock.Of <ILogger <PackageIsRepositorySignedValidator> >(); var config = ValidatorTestUtility.CreateValidatorConfig(requirePackageSignature: requirePackageSignature); return(new PackageIsRepositorySignedValidator(config, logger)); }
public async Task FailsIfUnequal( RegistrationIndexValidator validator, PackageRegistrationIndexMetadata v2, PackageRegistrationIndexMetadata v3) { await Assert.ThrowsAnyAsync <MetadataInconsistencyException>( () => validator.CompareIndexAsync(ValidatorTestUtility.GetFakeValidationContext(), v2, v3)); }
protected override RegistrationExistsValidator CreateValidator( IDictionary <FeedType, SourceRepository> feedToSource, ILogger <RegistrationExistsValidator> logger) { var config = ValidatorTestUtility.CreateValidatorConfig(); return(new RegistrationExistsValidator(config, logger)); }
protected override RegistrationVersionValidator CreateValidator( ILogger <RegistrationVersionValidator> logger) { var endpoint = ValidatorTestUtility.CreateRegistrationEndpoint(); var config = ValidatorTestUtility.CreateValidatorConfig(); return(new RegistrationVersionValidator(endpoint, config, logger)); }
protected override RegistrationRequireLicenseAcceptanceValidator CreateValidator( ILogger <RegistrationRequireLicenseAcceptanceValidator> logger) { var endpoint = ValidatorTestUtility.CreateRegistrationEndpoint(); var config = new ValidatorConfiguration("https://nuget.test/packages", requireRepositorySignature: false); return(new RegistrationRequireLicenseAcceptanceValidator(endpoint, config, logger)); }
private static IEnumerable <object[]> ValidatorTestData <T>(Func <IRegistrationIndexValidatorTestData, IEnumerable <Tuple <T, T> > > getPairs) { foreach (var testData in ValidatorTestUtility.GetImplementations <IRegistrationIndexValidatorTestData>()) { var validator = testData.CreateValidator(); foreach (var pair in getPairs(testData)) { yield return(new object[] { validator, pair.Item1, pair.Item2 }); } } }
public async Task SpecialCasesReturnAsExpected( RegistrationIndexValidator validator, PackageRegistrationIndexMetadata v2, PackageRegistrationIndexMetadata v3, bool shouldPass) { var compareTask = Task.Run(async() => await validator.CompareIndexAsync(ValidatorTestUtility.GetFakeValidationContext(), v2, v3)); if (shouldPass) { await compareTask; } else { await Assert.ThrowsAnyAsync <MetadataInconsistencyException>( () => compareTask); } }
protected PackageHasSignatureValidator CreateTarget(bool requirePackageSignature = true) { var config = ValidatorTestUtility.CreateValidatorConfig(requirePackageSignature: requirePackageSignature); return(new PackageHasSignatureValidator(config, _logger.Object)); }