Exemple #1
0
        public void EventToCommandBehavior()
        {
            var c    = new TestEventToCommandBehavior();
            var item = new ActionItem();

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

            Assert.AreEqual(true, item.IsMethod1Invoked);
        }
Exemple #2
0
        public void EventToCommandBehavior_With_Int_Parameter()
        {
            var c    = new TestEventToCommandBehavior();
            var item = new GenericActionItem <int>();

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

            Assert.AreEqual(true, item.IsMethod1Invoked);
            Assert.AreEqual(10, item.Method1Parameter);
        }
Exemple #3
0
        public void EventToCommandBehavior_With_Parameter()
        {
            var c    = new TestEventToCommandBehavior();
            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);
        }
Exemple #4
0
        public void EventToCommandBehavior_With_Converter()
        {
            var c    = new TestEventToCommandBehavior();
            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);
        }
Exemple #5
0
        public void EventToCommandBehavior_With_DateTime_Parameter()
        {
            var c    = new TestEventToCommandBehavior();
            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);
        }
Exemple #6
0
        public void EventToCommandBehavior_With_Converter_And_Culture()
        {
            var c    = new TestEventToCommandBehavior();
            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);
        }