Esempio n. 1
0
        public void NoParameter()
        {
            var control = new Control();

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

            command.Execute(null);

            Assert.AreEqual("<NULL>", control.Do_Argument);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }