public async Task Should_not_add_error_everything_defined() { var action = new FastlyAction { ServiceId = "APP", ApiKey = "KEY" }; var errors = await RuleActionValidator.ValidateAsync(action); Assert.Empty(errors); }
public async Task Should_add_error_if_api_key_not_defined() { var action = new FastlyAction { ServiceId = "APP", ApiKey = null }; var errors = await RuleActionValidator.ValidateAsync(action); Assert.NotEmpty(errors); }
public async Task Should_add_error_if_api_key_not_defined() { var action = new FastlyAction { ServiceId = "APP", ApiKey = null }; var errors = await RuleActionValidator.ValidateAsync(action); errors.ShouldBeEquivalentTo( new List <ValidationError> { new ValidationError("Api Key is required.", "ApiKey") }); }
public async Task Should_add_error_if_service_id_not_defined() { var action = new FastlyAction { ServiceId = null, ApiKey = "KEY" }; var errors = await RuleActionValidator.ValidateAsync(action); errors.ShouldBeEquivalentTo( new List <ValidationError> { new ValidationError("Service ID is required.", "ServiceId") }); }
public Task <IEnumerable <ValidationError> > Visit(FastlyAction action) { var errors = new List <ValidationError>(); if (string.IsNullOrWhiteSpace(action.ApiKey)) { errors.Add(new ValidationError("Api key is required.", nameof(action.ApiKey))); } if (string.IsNullOrWhiteSpace(action.ServiceId)) { errors.Add(new ValidationError("Service ID is required.", nameof(action.ServiceId))); } return(Task.FromResult <IEnumerable <ValidationError> >(errors)); }
public RuleActionDto Visit(FastlyAction action) { return(SimpleMapper.Map(action, new FastlyActionDto())); }