Beispiel #1
0
            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);
            }
Beispiel #2
0
        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();
        }
Beispiel #3
0
        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);