Exemple #1
0
        public void NoParameter()
        {
            var control = new Control();

            var command = CommandBinding.CreateCommand(control, "Do()");

            command.Execute(null);

            Assert.AreEqual("<NULL>", control.Do_Argument);
        }
Exemple #2
0
        public void InvalidParameter()
        {
            var control = new Control();

            var command = CommandBinding.CreateCommand(control, "Do(Blabla)");

            command.Execute(null);

            Assert.AreEqual("Blabla", control.Do_Argument);
        }
Exemple #3
0
        public void OverloadsWithDifferentTypesButObjectArgument()
        {
            var control = new Control
            {
                DirectObject = new OverloadType2(),
            };

            var command = CommandBinding.CreateCommand(control, "DoAmbiguous(DirectObject)");

            command.Execute(null);
            Assert.AreEqual(new OverloadType2().ToString(), control.Do_Argument);
        }
Exemple #4
0
        public void IndirectPropertySecondDegreeOfNullOfControlAsParameter()
        {
            var control = new Control
            {
                DataContext = null
            };

            var command = CommandBinding.CreateCommand(control, "DoAmbiguous(DataContext.Nested.AmbiguousProperty1)");

            command.Execute(null);

            Assert.AreEqual("<NULL1>", control.Do_Argument);
        }
Exemple #5
0
        public void IndirectPropertyOfNullOfControlAsParameter()
        {
            var control = new Control
            {
                DataContext = null
            };

            var command = CommandBinding.CreateCommand(control, "Do(DataContext.Input)");

            command.Execute(null);

            Assert.AreEqual("<NULL>", control.Do_Argument);
        }
Exemple #6
0
        public void DirectPropertyOfControlAsObjectParameter()
        {
            var control = new Control
            {
                AmbiguousProperty2 = new OverloadType2(),
            };

            var command = CommandBinding.CreateCommand(control, "DoObject(AmbiguousProperty2)");

            command.Execute(null);

            Assert.AreEqual(new OverloadType2().ToString(), control.Do_Argument);
        }
Exemple #7
0
        public void DirectPropertyOfControlAsParameter()
        {
            var control = new Control
            {
                DirectProperty1 = "direct",
            };

            var command = CommandBinding.CreateCommand(control, "Do(DirectProperty1)");

            command.Execute(null);

            Assert.AreEqual("direct", control.Do_Argument);
        }
Exemple #8
0
        public void ContextParameter()
        {
            var control = new Control();

            var command = CommandBinding.CreateCommand(control, "DoObjects(sender,sender.Input)", new Dictionary <string, object> {
                { "sender", new ViewModel {
                      Input = "blabla"
                  } }
            });

            command.Execute(null);

            Assert.AreEqual(new ViewModel().ToString(), control.Do_Argument);
            Assert.AreEqual("blabla", control.Do_Argument2);
        }
Exemple #9
0
        public void IndirectPropertyOfControlAsParameter()
        {
            var control = new Control
            {
                DataContext = new ViewModel {
                    Input = "nested"
                }
            };

            var command = CommandBinding.CreateCommand(control, "Do(DataContext.Input)");

            command.Execute(null);

            Assert.AreEqual("nested", control.Do_Argument);
        }
Exemple #10
0
        public void OverloadsWithIndirectParameterOfDifferentTypesButNull()
        {
            var control = new Control
            {
                Nested = null
            };

            var command = CommandBinding.CreateCommand(control, "DoAmbiguous(Nested.AmbiguousProperty2)");

            command.Execute(null);
            Assert.AreEqual("<NULL2>", control.Do_Argument);

            command = CommandBinding.CreateCommand(control, "DoAmbiguous(Nested.AmbiguousProperty1)");
            command.Execute(null);
            Assert.AreEqual("<NULL1>".ToString(), control.Do_Argument);
        }
Exemple #11
0
        public void OverloadsWithDifferentTypesButNullAndInteger()
        {
            var control = new Control
            {
                AmbiguousProperty1 = null,
                AmbiguousProperty2 = null,
            };

            var command = CommandBinding.CreateCommand(control, "DoAmbiguous(AmbiguousProperty2, 123)");

            command.Execute(null);
            Assert.AreEqual("<NULL2>_123", control.Do_Argument);

            command = CommandBinding.CreateCommand(control, "DoAmbiguous(AmbiguousProperty1, 321)");
            command.Execute(null);
            Assert.AreEqual("<NULL1>_321", control.Do_Argument);
        }
Exemple #12
0
        public void OverloadsWithDifferentTypesAndInteger()
        {
            var control = new Control
            {
                AmbiguousProperty1 = new OverloadType1(),
                AmbiguousProperty2 = new OverloadType2(),
            };

            var command = CommandBinding.CreateCommand(control, "DoAmbiguous(AmbiguousProperty2, 123)");

            command.Execute(null);
            Assert.AreEqual(new OverloadType2().ToString() + "_123", control.Do_Argument);

            command = CommandBinding.CreateCommand(control, "DoAmbiguous(AmbiguousProperty1, 321)");
            command.Execute(null);
            Assert.AreEqual(new OverloadType1().ToString() + "_321", control.Do_Argument);
        }
Exemple #13
0
        public void OverloadsWithDifferentTypesButNull()
        {
            var control = new Control
            {
                AmbiguousProperty1 = null,
                AmbiguousProperty2 = null,
            };

            var command = CommandBinding.CreateCommand(control, "DoAmbiguous(AmbiguousProperty2)");

            command.Execute(null);
            Assert.AreEqual("<NULL2>", control.Do_Argument);

            command = CommandBinding.CreateCommand(control, "DoAmbiguous(AmbiguousProperty1)");
            command.Execute(null);
            Assert.AreEqual("<NULL1>".ToString(), control.Do_Argument);
        }