Beispiel #1
0
        public void InvalidEventNameShouldThrowArgumentExceptionText()
        {
            var behavior = new MockEventToCommandBehavior
            {
                EventName = "OnItemTapped"
            };
            var listView = new ListView();

            Assert.Throws <ArgumentException>(() => listView.Behaviors.Add(behavior));
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
        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);
        }