Пример #1
0
        public void InvokeCommandAction()
        {
            var c    = new TestInvokeCommandAction();
            var item = new ActionItem();

            c.Command = item.MyCommand1;
            c.TestInvoke();

            Assert.AreEqual(true, item.IsMethod1Invoked);
        }
Пример #2
0
        public void InvokeCommandAction_With_Int_Parameter()
        {
            var c    = new TestInvokeCommandAction();
            var item = new GenericActionItem <int>();

            c.Command          = item.MyCommand1;
            c.CommandParameter = 10;
            c.TestInvoke();

            Assert.AreEqual(true, item.IsMethod1Invoked);
            Assert.AreEqual(10, item.Method1Parameter);
        }
Пример #3
0
        public void InvokeCommandAction_With_Parameter()
        {
            var c    = new TestInvokeCommandAction();
            var item = new ActionItem();

            c.Command          = item.MyCommand2;
            c.CommandParameter = "My parameter";
            c.TestInvoke();

            Assert.AreEqual(true, item.IsMethod2Invoked);
            Assert.AreEqual("My parameter", item.Method2Parameter);
        }
Пример #4
0
        public void InvokeCommandAction_With_Converter()
        {
            var c    = new TestInvokeCommandAction();
            var item = new GenericActionItem <bool>();

            c.Command          = item.MyCommand1;
            c.CommandParameter = "true";
            c.Converter        = new StringToBoolConverter();
            c.TestInvoke();

            Assert.AreEqual(true, item.IsMethod1Invoked);
            Assert.AreEqual(true, item.Method1Parameter);
        }
Пример #5
0
        public void InvokeCommandAction_With_DateTime_Parameter()
        {
            var c    = new TestInvokeCommandAction();
            var item = new GenericActionItem <DateTime>();

            var date = new DateTime(2019, 07, 18);

            c.Command          = item.MyCommand1;
            c.CommandParameter = date;
            c.TestInvoke();

            Assert.AreEqual(true, item.IsMethod1Invoked);
            Assert.AreEqual(date, item.Method1Parameter);
        }
Пример #6
0
        public void InvokeCommandAction_With_Converter_And_Culture()
        {
            var c    = new TestInvokeCommandAction();
            var item = new GenericActionItem <DateTime>();

            var date           = new DateTime(2019, 07, 18);
            var dateAsStringFr = date.ToString(CultureInfo.GetCultureInfo("fr")); // 18/07/2019 00:00:00

            c.Command          = item.MyCommand1;
            c.CommandParameter = dateAsStringFr;
            c.Converter        = new GenericConverter <string, DateTime>();
            c.ConverterCulture = CultureInfo.GetCultureInfo("fr");
            c.TestInvoke();

            Assert.AreEqual(true, item.IsMethod1Invoked);
            Assert.AreEqual(date, item.Method1Parameter);
        }