public void InvalidEventNameShouldThrowArgumentExceptionText() { var behavior = new MockEventToCommandBehavior { EventName = "OnItemTapped" }; var listView = new ListView(); Assert.Throws <ArgumentException>(() => listView.Behaviors.Add(behavior)); }
public void CommandCanExecuteTest() { var behavior = new MockEventToCommandBehavior { EventName = "ItemTapped", Command = new Command(() => Assert.True(false), () => false) }; var listView = new ListView(); listView.Behaviors.Add(behavior); behavior.RaiseEvent(listView, null); }
public void CommandCanExecuteWithParameterShouldNotExecuteTest() { bool shouldExecute = false; var behavior = new MockEventToCommandBehavior { EventName = "ItemTapped", CommandParameter = shouldExecute, Command = new Command <string>(o => Assert.True(false), o => o.Equals(true)) }; var listView = new ListView(); listView.Behaviors.Add(behavior); behavior.RaiseEvent(listView, null); }
public void CommandExecutedWhenEventFiresText() { bool executedCommand = false; var behavior = new MockEventToCommandBehavior { EventName = "ItemTapped", Command = new Command(() => { executedCommand = true; }) }; var listView = new ListView(); listView.Behaviors.Add(behavior); behavior.RaiseEvent(listView, null); Assert.True(executedCommand); }
public void CommandWithConverterTest() { const string item = "ItemProperty"; bool executedCommand = false; var behavior = new MockEventToCommandBehavior { EventName = "ItemTapped", EventArgsConverter = new ItemTappedEventArgsConverter(false), Command = new Command <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); }