public void TestDoubleAdd()
        {
            var menu = new NavigationMenu();

            var child = new ContentPage {
                Icon    = "img.img",
                Content = new View()
            };

            menu.Add(child);

            bool signaled = false;

            menu.PropertyChanged += (sender, args) => {
                switch (args.PropertyName)
                {
                case "Targets":
                    signaled = true;
                    break;
                }
            };

            menu.Add(child);

            Assert.True(menu.Targets.Contains(child));
            Assert.False(signaled);
        }
        public async Task TestSendTargetSelected()
        {
            var menu    = new NavigationMenu();
            var navForm = new NavigationPage();

            await navForm.PushAsync(new ContentPage {
                Title   = "Menu",
                Content = menu
            });

            bool pushed = false;

            navForm.Pushed += (sender, arg) => pushed = true;

            var child = new ContentPage {
                Icon    = "img.jpg",
                Content = new View()
            };

            menu.Add(child);

            menu.SendTargetSelected(child);

            Assert.True(pushed);
            Assert.AreEqual(child, navForm.CurrentPage);
        }
Example #3
0
        public ExploderViewModel(CalendarGraph CalendarGraph) ///, IEnumerable<Element> Path
        {
            if (CalendarGraph == null)
            {
                return;
            }
            this.CalendarGraph = CalendarGraph;

            int i = CalendarGraph.ActiveElement.Depth;

            NavigationMenu.Add(CalendarGraph.ActiveElement);
            var cursor = CalendarGraph.ActiveElement.Parent;

            if (cursor != null)
            {
                while (cursor.Id != -1)
                {
                    NavigationMenu.Add(cursor);

                    cursor = cursor.Parent;
                    if (cursor == null)
                    {
                        break;
                    }
                }
            }



            SelectedElement = CalendarGraph.ActiveElement;
        }
        public void IconNotSet()
        {
            var menu             = new NavigationMenu();
            var childWithoutIcon = new ContentPage {
                Title = "I have no image"
            };

            var ex = Assert.Throws <Exception> (() => menu.Add(childWithoutIcon));

            Assert.That(ex.Message, Is.EqualTo("Icon must be set for each page before adding them to a Navigation Menu"));
        }