public async Task Should_add_error_if_index_type_is_null() { var action = new ElasticSearchAction { Host = new Uri("http://host", UriKind.Absolute), IndexName = "squidex", IndexType = null }; var errors = await RuleActionValidator.ValidateAsync(action); Assert.NotEmpty(errors); }
public async Task Should_not_add_error_if_values_are_valid() { var action = new ElasticSearchAction { Host = new Uri("http://host", UriKind.Absolute), IndexName = "squidex", IndexType = "squidex" }; var errors = await RuleActionValidator.ValidateAsync(action); Assert.Empty(errors); }
public async Task Should_add_error_if_host_is_relative() { var action = new ElasticSearchAction { Host = new Uri("/rel", UriKind.Relative), IndexName = "squidex", IndexType = "squidex" }; var errors = await RuleActionValidator.ValidateAsync(action); Assert.NotEmpty(errors); }
public async Task Should_add_error_if_host_is_null() { var action = new ElasticSearchAction { Host = null, IndexName = "squidex", IndexType = "squidex" }; var errors = await RuleActionValidator.ValidateAsync(action); Assert.NotEmpty(errors); }
public async Task Should_add_error_if_index_type_is_null() { var action = new ElasticSearchAction { Host = new Uri("http://host", UriKind.Absolute), IndexName = "squidex", IndexType = null }; var errors = await RuleActionValidator.ValidateAsync(action); errors.Should().BeEquivalentTo( new List <ValidationError> { new ValidationError("Type name is required.", "IndexType") }); }
public async Task Should_add_error_if_host_is_relative() { var action = new ElasticSearchAction { Host = new Uri("/rel", UriKind.Relative), IndexName = "squidex", IndexType = "squidex" }; var errors = await RuleActionValidator.ValidateAsync(action); errors.Should().BeEquivalentTo( new List <ValidationError> { new ValidationError("Host is required and must be an absolute URL.", "Host") }); }
public Task <IEnumerable <ValidationError> > Visit(ElasticSearchAction action) { var errors = new List <ValidationError>(); if (action.Host == null || !action.Host.IsAbsoluteUri) { errors.Add(new ValidationError("Host is required and must be an absolute URL.", nameof(action.Host))); } if (string.IsNullOrWhiteSpace(action.IndexType)) { errors.Add(new ValidationError("TypeName is required.", nameof(action.IndexType))); } if (string.IsNullOrWhiteSpace(action.IndexName)) { errors.Add(new ValidationError("IndexName is required.", nameof(action.IndexName))); } return(Task.FromResult <IEnumerable <ValidationError> >(errors)); }
public RuleActionDto Visit(ElasticSearchAction action) { return(SimpleMapper.Map(action, new ElasticSearchActionDto())); }