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); }
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); }
public void CallMethodAction_With_Int_Parameter() { var c = new TestCallMethodAction(); var item = new GenericActionItem <int>(); c.TargetObject = item; c.MethodName = "Method1"; c.Parameter = 10; c.TestInvoke(); Assert.AreEqual(true, item.IsMethod1Invoked); Assert.AreEqual(10, item.Method1Parameter); }
public void ChangePropertyAction_Converts_Value() { var c = new TestChangePropertyAction(); var item = new GenericActionItem <Brush> { }; c.TargetObject = item; c.PropertyPath = "MyProperty"; c.Value = "Red"; c.TestInvoke(); Assert.AreEqual(new SolidColorBrush(Colors.Red).ToString(), item.MyProperty.ToString()); }
public void ChangePropertyAction_Converts_Int() { var c = new TestChangePropertyAction(); var item = new GenericActionItem <int> { }; c.TargetObject = item; c.PropertyPath = "MyProperty"; c.Value = "10"; c.TestInvoke(); Assert.AreEqual(10, item.MyProperty); }
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); }
public void InvokeCommandAction_With_Int_Nullable_Parameter() { var c = new TestInvokeCommandAction(); var item = new GenericActionItem <int>(); int?n = 10; c.Command = item.MyCommand1; c.CommandParameter = n; c.TestInvoke(); Assert.AreEqual(true, item.IsMethod1Invoked); Assert.AreEqual(n, item.Method1Parameter); }
public void CallMethodAction_With_DateTime_Parameter() { var c = new TestCallMethodAction(); var item = new GenericActionItem <DateTime>(); var date = new DateTime(2019, 07, 18); c.TargetObject = item; c.MethodName = "Method1"; c.Parameter = date; c.TestInvoke(); Assert.AreEqual(true, item.IsMethod1Invoked); Assert.AreEqual(date, item.Method1Parameter); }
public void ChangePropertyAction_With_Culture() { var c = new TestChangePropertyAction(); 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.TargetObject = item; c.PropertyPath = "MyProperty"; c.Value = dateAsStringFr; c.Culture = CultureInfo.GetCultureInfo("fr"); c.TestInvoke(); Assert.AreEqual(date, item.MyProperty); }
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); }
public void InvokeCommandAction_With_DateTime_Conversion_And_Invariant_Culture() { var c = new TestInvokeCommandAction(); var item = new GenericActionItem <DateTime>(); var date = new DateTime(2019, 07, 18); var dateAsString = date.ToString(CultureInfo.InvariantCulture); // 18/07/2019 00:00:00 => invariant 07/18/2019 00:00:00 c.Command = item.MyCommand1; c.CommandParameter = dateAsString; c.Converter = new GenericConverter <string, DateTime>(); c.ConverterCulture = CultureInfo.InvariantCulture; c.TestInvoke(); Assert.AreEqual(true, item.IsMethod1Invoked); Assert.AreEqual(date, item.Method1Parameter); }
public void InvokeCommandAction_With_Converter_Pass_Command_Parameter() { 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; var converter = new GenericConverter <string, DateTime>(); c.Converter = converter; c.ConverterCulture = CultureInfo.GetCultureInfo("fr"); c.ConverterParameter = "My parameter"; c.TestInvoke(); Assert.AreEqual(true, item.IsMethod1Invoked); Assert.AreEqual(date, item.Method1Parameter); Assert.AreEqual(CultureInfo.GetCultureInfo("fr"), converter.Culture); Assert.AreEqual("My parameter", converter.Parameter); }