public void When_building_with_16_args_Then_it_fails()
        {
            var builder           = new PartialActionBuilder();
            var delegateArguments = new object[] { "a1", 1, 3.0f, "a4", 5, 6.0f, "a7", 8, 9.0f, "a10", 11, 12f, "a13", 14, 15f, "a16" };

            Assert.Throws <ArgumentException>(() => ((Action)(() => builder.Build <object>(new CompiledMatchHandlerWithArguments(null, delegateArguments))))());
        }
        public void Given_a_15_arguments_delegate_When_building_and_invoking_Then_the_supplied_function_is_called()
        {
            var    builder           = new PartialActionBuilder();
            object updatedValue      = null;
            var    delegateArguments = new object[] { "a1", 1, 3.0f, "a4", 5, 6.0f, "a7", 8, 9.0f, "a10", 11, 12f, "a13", 14, 15f };
            var    updatedArgs       = new object[delegateArguments.Length];
            Func <object, string, int, float, string, int, float, string, int, float, string, int, float, string, int, float, bool> deleg = (value, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15) =>
            {
                updatedValue    = value;
                updatedArgs[0]  = a1;
                updatedArgs[1]  = a2;
                updatedArgs[2]  = a3;
                updatedArgs[3]  = a4;
                updatedArgs[4]  = a5;
                updatedArgs[5]  = a6;
                updatedArgs[6]  = a7;
                updatedArgs[7]  = a8;
                updatedArgs[8]  = a9;
                updatedArgs[9]  = a10;
                updatedArgs[10] = a11;
                updatedArgs[11] = a12;
                updatedArgs[12] = a13;
                updatedArgs[13] = a14;
                updatedArgs[14] = a15;
                return(true);
            };

            var partialAction = builder.Build <object>(new CompiledMatchHandlerWithArguments(deleg, delegateArguments));

            partialAction("value");
            Assert.Same("value", updatedValue);
            AssertAreSame(delegateArguments, updatedArgs);
        }
        public void Given_a_0_arguments_delegate_When_building_and_invoking_Then_the_supplied_function_is_called()
        {
            var builder = new PartialActionBuilder();
            object updatedValue = null;
            Func<object, bool> deleg = value => { updatedValue = value; return true; };

            var partialAction = builder.Build<object>(new CompiledMatchHandlerWithArguments(deleg, new object[0]));
            partialAction("value");
            Assert.Same(updatedValue, "value");
        }
        public void Given_a_0_arguments_delegate_When_building_and_invoking_Then_the_supplied_function_is_called()
        {
            var    builder            = new PartialActionBuilder();
            object updatedValue       = null;
            Func <object, bool> deleg = value => { updatedValue = value; return(true); };

            var partialAction = builder.Build <object>(new CompiledMatchHandlerWithArguments(deleg, new object[0]));

            partialAction("value");
            Assert.Same(updatedValue, "value");
        }
        public void Given_a_1_arguments_delegate_When_building_and_invoking_Then_the_supplied_function_is_called()
        {
            var builder = new PartialActionBuilder();
            object updatedValue = null;
            var delegateArguments = new object[] { "a1" };
            var updatedArgs = new object[delegateArguments.Length];
            Func<object, string, bool> deleg = (value, a1) =>
            {
                updatedValue = value;
                updatedArgs[0] = a1;
                return true;
            };

            var partialAction = builder.Build<object>(new CompiledMatchHandlerWithArguments(deleg, delegateArguments));
            partialAction("value");
            Assert.Same("value", updatedValue);
            AssertAreSame(delegateArguments, updatedArgs);
        }
        public void Given_a_1_arguments_delegate_When_building_and_invoking_Then_the_supplied_function_is_called()
        {
            var    builder                    = new PartialActionBuilder();
            object updatedValue               = null;
            var    delegateArguments          = new object[] { "a1" };
            var    updatedArgs                = new object[delegateArguments.Length];
            Func <object, string, bool> deleg = (value, a1) =>
            {
                updatedValue   = value;
                updatedArgs[0] = a1;
                return(true);
            };

            var partialAction = builder.Build <object>(new CompiledMatchHandlerWithArguments(deleg, delegateArguments));

            partialAction("value");
            Assert.Same("value", updatedValue);
            AssertAreSame(delegateArguments, updatedArgs);
        }
 public void When_building_with_16_args_Then_it_fails()
 {
     var builder = new PartialActionBuilder();
     var delegateArguments = new object[] { "a1", 1, 3.0f, "a4", 5, 6.0f, "a7", 8, 9.0f, "a10", 11, 12f, "a13", 14, 15f,"a16" };
     Assert.Throws<ArgumentException>(() => ((Action) (() => builder.Build<object>(new CompiledMatchHandlerWithArguments(null, delegateArguments))))());
 }
        public void Given_a_15_arguments_delegate_When_building_and_invoking_Then_the_supplied_function_is_called()
        {
            var builder = new PartialActionBuilder();
            object updatedValue = null;
            var delegateArguments = new object[] { "a1", 1, 3.0f, "a4", 5, 6.0f, "a7", 8, 9.0f, "a10", 11, 12f, "a13", 14,15f };
            var updatedArgs = new object[delegateArguments.Length];
            Func<object, string, int, float, string, int, float, string, int, float, string, int, float, string, int, float,bool> deleg = (value, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15) =>
            {
                updatedValue = value;
                updatedArgs[0] = a1;
                updatedArgs[1] = a2;
                updatedArgs[2] = a3;
                updatedArgs[3] = a4;
                updatedArgs[4] = a5;
                updatedArgs[5] = a6;
                updatedArgs[6] = a7;
                updatedArgs[7] = a8;
                updatedArgs[8] = a9;
                updatedArgs[9] = a10;
                updatedArgs[10] = a11;
                updatedArgs[11] = a12;
                updatedArgs[12] = a13;
                updatedArgs[13] = a14;
                updatedArgs[14] = a15;
                return true;
            };

            var partialAction = builder.Build<object>(new CompiledMatchHandlerWithArguments(deleg, delegateArguments));
            partialAction("value");
            Assert.Same("value", updatedValue);
            AssertAreSame(delegateArguments, updatedArgs);
        }