Пример #1
0
        public void Should_get_value_from_argument()
        {
            var action    = ActionMethod.From <ArgumentHandler>(x => x.Action(null, null));
            var parameter = action.MethodDescriptor.Parameters
                            .First(x => x.Name == "value");
            var actionParameter = new ActionParameter(action, parameter);
            var arguments       = new object[] { null, "fark" };

            actionParameter.GetArgument(arguments).ShouldEqual("fark");
        }
Пример #2
0
        public void Should_return_null_if_property_argument_is_null()
        {
            var action    = ActionMethod.From <ArgumentHandler>(x => x.Action(null, null));
            var parameter = action.MethodDescriptor.Parameters
                            .First(x => x.Name == "value");
            var property        = parameter.ParameterType.Properties.First();
            var actionParameter = new ActionParameter(action, parameter, property);
            var arguments       = new object[2];

            actionParameter.GetArgument(arguments).ShouldBeNull();
        }
Пример #3
0
        public void Should_get_value_from_argument_property()
        {
            var action    = ActionMethod.From <ArgumentHandler>(x => x.Action(null, null));
            var parameter = action.MethodDescriptor.Parameters
                            .First(x => x.Name == "model");
            var property        = parameter.ParameterType.Properties.First();
            var actionParameter = new ActionParameter(action, parameter, property);
            var arguments       = new object[] { new ArgumentHandler.Model {
                                                     Value = "fark"
                                                 }, null };

            actionParameter.GetArgument(arguments).ShouldEqual("fark");
        }