public void Command_EventArgsParameterPath_Nested_When_ChildIsNull() { var executedCommand = false; var behavior = new EventToCommandBehaviorMock { EventName = "ItemTapped", EventArgsParameterPath = "Item.AProperty", Command = new DelegateCommand <object>(o => { executedCommand = true; Assert.Null(o); }) }; var listView = new ListView(); listView.Behaviors.Add(behavior); behavior.RaiseEvent(listView, new ItemTappedEventArgs(listView, null, 0)); Assert.True(executedCommand); }
public void Command_CanExecuteWithParameterShouldExecute() { var shouldExeute = bool.TrueString; var executedCommand = false; var behavior = new EventToCommandBehaviorMock { EventName = "ItemTapped", CommandParameter = shouldExeute, Command = new DelegateCommand <string>(o => { executedCommand = true; Assert.True(true); }, o => o.Equals(bool.TrueString)) }; var listView = new ListView(); listView.Behaviors.Add(behavior); behavior.RaiseEvent(listView, null); Assert.True(executedCommand); }
public void Command_Converter() { const string item = "ItemProperty"; var executedCommand = false; var behavior = new EventToCommandBehaviorMock { EventName = "ItemTapped", EventArgsConverter = new ItemTappedEventArgsConverter(false), Command = new DelegateCommand <string>(o => { executedCommand = true; Assert.NotNull(o); Assert.Equal(item, o); }) }; var listView = new ListView(); listView.Behaviors.Add(behavior); behavior.RaiseEvent(listView, new ItemTappedEventArgs(listView, item)); Assert.True(executedCommand); }
public void Command_OrderOfExecution() { const string commandParameter = "ItemProperty"; var converter = new ItemTappedEventArgsConverter(false); var behavior = new EventToCommandBehaviorMock { EventName = "ItemTapped", EventArgsConverter = converter, CommandParameter = commandParameter, Command = new DelegateCommand <string>(o => { Assert.NotNull(o); Assert.Equal(commandParameter, o); Assert.False(converter.HasConverted); }) }; var listView = new ListView(); listView.Behaviors.Add(behavior); behavior.RaiseEvent(listView, new ItemTappedEventArgs(listView, commandParameter)); }
public void Command_EventArgsParameterPath_Nested() { dynamic item = new { AProperty = "Value" }; var behavior = new EventToCommandBehaviorMock { EventName = "ItemTapped", EventArgsParameterPath = "Item.AProperty", Command = new DelegateCommand <object>(o => { Assert.NotNull(o); Assert.Equal("Value", o); }) }; var listView = new ListView(); listView.Behaviors.Add(behavior); behavior.RaiseEvent(listView, new ItemTappedEventArgs(listView, item)); }