private bool IsValidPackage(PackageServiceModel package) { IPackageValidator validator = PackageValidatorFactory.GetValidator( package.PackageType, package.ConfigType); // Bypass validation for custom _config type return(validator == null || validator.Validate()); }
public void Create_WhenValidatorConfigIsNull_Throws() { var factory = new PackageValidatorFactory(_loggerFactory.Object); var exception = Assert.Throws <ArgumentNullException>( () => factory.Create( _galleryUrl, _indexUrl, _auditingStorageFactory, Enumerable.Empty <EndpointFactory.Input>(), _messageHandlerFactory, validatorConfig: null)); Assert.Equal("validatorConfig", exception.ParamName); }
public void Create_WhenIndexUrlIsNullOrEmpty_Throws(string indexUrl) { var factory = new PackageValidatorFactory(_loggerFactory.Object); var exception = Assert.Throws <ArgumentException>( () => factory.Create( _galleryUrl, indexUrl, _auditingStorageFactory, Enumerable.Empty <EndpointFactory.Input>(), _messageHandlerFactory, _validatorConfiguration)); Assert.Equal("indexUrl", exception.ParamName); Assert.StartsWith("The argument must not be null or empty.", exception.Message); }
public void Create_WhenMessageHandlerFactoryIsNull_Throws() { var factory = new PackageValidatorFactory(_loggerFactory.Object); const Func <HttpMessageHandler> messageHandlerFactory = null; var exception = Assert.Throws <ArgumentNullException>( () => factory.Create( _galleryUrl, _indexUrl, _auditingStorageFactory, Enumerable.Empty <EndpointFactory.Input>(), messageHandlerFactory, _validatorConfiguration)); Assert.Equal("messageHandlerFactory", exception.ParamName); }
public void Create_WhenEndpointInputsIsNull_Throws() { var factory = new PackageValidatorFactory(_loggerFactory.Object); const IEnumerable <EndpointFactory.Input> endpointInputs = null; var exception = Assert.Throws <ArgumentNullException>( () => factory.Create( _galleryUrl, _indexUrl, _auditingStorageFactory, endpointInputs, _messageHandlerFactory, _validatorConfiguration)); Assert.Equal("endpointInputs", exception.ParamName); }