Esempio n. 1
0
        public void WhenFilterStringIsNotSet_ItemsAreNotFiltered()
        {
            // Arrange
            var navGroupViewModel = new NavGroupViewModel();
            var navigationItems = new List<MockNavigationItemInfo>
                                      {
                                          new MockNavigationItemInfo(1, "Item 1"),
                                          new MockNavigationItemInfo(2, "abcd"),
                                          new MockNavigationItemInfo(3, "Test item"),
                                          new MockNavigationItemInfo(4, "test ITEM 3"),
                                          new MockNavigationItemInfo(5, "zzz")
                                      };

            var groupInfo = new MockNavigationGroupInfo(navigationItems);

            navGroupViewModel.ItemFactory = new[]
                                                {
                                                    new ExportFactory<NavItemViewModel>(() => 
                                                        {
                                                            return new Tuple<NavItemViewModel, Action>(Mock.Create<NavItemViewModel>(), () => { });
                                                        })
                                                };

            navGroupViewModel.Initialize(groupInfo, null);
            navGroupViewModel.FilterString = string.Empty;

            // Act
            var filteredItems = navGroupViewModel.Items.View;

            // Assert
            Assert.AreEqual(filteredItems.Cast<NavItemViewModel>().Count(), 5);
        }
 private void NavigationMenuItemLoaded(object obj, RoutedEventArgs e)
 {
     this.data = (NavGroupViewModel)DataContext;
 }
Esempio n. 3
0
        public void WhenFilterStringIsSet_ItemsAreFiltered()
        {
            // Arrange
            var navGroupViewModel = new NavGroupViewModel();
            var navigationItems = new List<MockNavigationItemInfo>
                                      {
                                          new MockNavigationItemInfo(1, "Item 1"),
                                          new MockNavigationItemInfo(2, "abcd"),
                                          new MockNavigationItemInfo(3, "Test item"),
                                          new MockNavigationItemInfo(4, "test ITEM 3"),
                                          new MockNavigationItemInfo(5, "zzz")
                                      };

            var groupInfo = new MockNavigationGroupInfo(navigationItems);

            navGroupViewModel.ItemFactory = new[]
                                                {
                                                    new ExportFactory<NavItemViewModel>(() => 
                                                        {
                                                            var navItemViewModelMock = Mock.Create<NavItemViewModel>();
                                                            var eventAggregatorMock = Mock.Create<IEventAggregator>();
                                                            Mock.Arrange(() => eventAggregatorMock.Subscribe(Arg.IsAny<IEventSink<LibraryDownloadEvent>>())).DoNothing();
                                                            Mock.Arrange(() => navItemViewModelMock.EventAggregator).Returns(eventAggregatorMock);
                                                            Mock.Arrange(() => navItemViewModelMock.Initialize(Arg.IsAny<NavigationItemInfo>(),Arg.IsAny<string>(), null)).CallOriginal();

                                                            return new Tuple<NavItemViewModel, Action>(navItemViewModelMock, () => { });
                                                        })
                                                };
            navGroupViewModel.Initialize(groupInfo, null);
            navGroupViewModel.FilterString = "Item";

            // Act
            var filteredItems = navGroupViewModel.Items.View;

            // Assert
            Assert.AreEqual(filteredItems.Cast<NavItemViewModel>().Count(), 3);
            Assert.AreEqual(filteredItems.Cast<NavItemViewModel>().Any((itemViewModel) => itemViewModel.Name == "Item 1"), true);
            Assert.AreEqual(filteredItems.Cast<NavItemViewModel>().Any((itemViewModel) => itemViewModel.Name == "Test item"), true);
            Assert.AreEqual(filteredItems.Cast<NavItemViewModel>().Any((itemViewModel) => itemViewModel.Name == "test ITEM 3"), true);
        }
Esempio n. 4
0
 public void NotifyPropertiesGetSet_Test()
 {
     var item = new NavGroupViewModel();
     TestsHelper.TestPropertyWithNotifyPropertyChanged(item, () => item.FilterString);
     TestsHelper.TestPropertyWithNotifyPropertyChanged(item, () => item.IsExpanded);
 }