コード例 #1
0
ファイル: Startup.cs プロジェクト: jgabrielfreitas/ZeDeX
            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);
            }
コード例 #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();
        }
コード例 #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();
        }
コード例 #4
0
 set => SetValue(InvalidProperty, value);