public void ParameterOfTypeInt() { var vm = new ViewModelCoffe(); var behavior = new EventToCommandBehavior <int> { EventName = nameof(ListView.ItemTapped), Command = vm.SelectedCommand, CommandParameter = 2 }; var nullArgs = new object?[] { null, null }; TriggerEventToCommandBehavior(behavior, nullArgs); }
public void NoExceptionWhenTheSelectedItemIsNull() { var vm = new ViewModelCoffe(); var behavior = new EventToCommandBehavior <Coffee> { EventName = nameof(ListView.ItemTapped), EventArgsConverter = new ItemSelectedEventArgsConverter(), Command = vm.SelectedCommand }; Assert.Null(vm.CoffeeName); var coffeNull = default(Coffee); var notNullArgs = new object?[] { null, new SelectedItemChangedEventArgs(coffeNull, -1) }; TriggerEventToCommandBehavior(behavior, notNullArgs); Assert.Null(vm.CoffeeName); }
public void NoExceptionWhenTheEventArgsAreNotNull_InheritedType() { var vm = new ViewModelCoffe(); var behavior = new EventToCommandBehavior <Coffee> { EventName = nameof(ListView.ItemTapped), EventArgsConverter = new ItemSelectedEventArgsConverter(), Command = vm.SelectedCommand }; Assert.Null(vm.CoffeeName); var coffe = new Starbucks { Id = 1, Name = "Latte" }; var eventArgs = new SelectedItemChangedEventArgs(coffe, 1); var notNullArgs = new object?[] { null, eventArgs }; TriggerEventToCommandBehavior(behavior, notNullArgs); Assert.AreEqual(coffe.Name, vm.CoffeeName); }