private static IEnumerable <InvalidProperty> GetInvalidProperties(ActionExecutingContext context) { var result = new List <InvalidProperty>(); foreach (var state in context.ModelState) { var invalidProperty = new InvalidProperty(); invalidProperty.Name = state.Key; invalidProperty.Details = state.Value.Errors.Select(p => p.ErrorMessage); result.Add(invalidProperty); } return(result); }
public void FieldSpecified_ThrowsException() { var invalid = new InvalidProperty("property"); var remute = new Remute(); try { invalid = remute.With(invalid, x => x.Field1, "test"); } catch (NotSupportedException ex) when(ex.Message == $"Unable to process expression. Expression: 'x.Field1'.") { return; } Assert.Fail(); }
public void UnableToFindProperty_ThrowsException() { var invalid = new InvalidProperty("property"); var remute = new Remute(); try { invalid = remute.With(invalid, x => x.Property1, "test"); } catch (Exception ex) when(ex.Message == $"Unable to find appropriate property to use as a constructor parameter 'property'. Type '{nameof(InvalidProperty)}'. Consider to use {nameof(ActivationConfiguration)} parameter.") { return; } Assert.Fail(); }
set => SetValue(InvalidProperty, value);