Esempio n. 1
0
        public ItemListView()
        {
            InitializeComponent();
            this.iEventAggregator = Event.EventInstance.EventAggregator;

            ItemListViewModel = new ItemListViewModel(Event.EventInstance.EventAggregator);
            this.DataContext = ItemListViewModel;

            SetPropertyChangedMap();
            ItemListViewModel.PropertyChanged += PropertyChangedHandler;
        }
        public void TestMoveDown(int numMoves)
        {
            ViewEventArgs moveDownEventArgs = new ViewEventArgs("ITEMLIST_MOVE_DOWN", new string[] { numMoves.ToString() });
            ItemListViewModel viewModel = new ItemListViewModel(eventAggregator);
            for (int i = 1; i <= viewModel.AllItemNames.Count() + 1; i++)
            {
                int expected = viewModel.SelectedItemIndex + numMoves;
                if (expected > viewModel.AllItemNames.Count() - 1)
                {
                    expected = viewModel.AllItemNames.Count() - 1;
                }
                this.eventAggregator.GetEvent<PubSubEvent<ViewEventArgs>>().Publish(moveDownEventArgs);

                int actual = viewModel.SelectedItemIndex;

                Assert.IsTrue(expected == actual, "Move Down failed. Expected: " + expected + " Actual: " + actual);
            }
        }
        public void TestMoveRight()
        {
            ViewEventArgs moveRightEventArgs = new ViewEventArgs("ITEMLIST_MOVE_RIGHT", new string[] { });
            ItemListViewModel viewModel = new ItemListViewModel(eventAggregator);

            for (int i = 1; i <= viewModel.ItemLists.GetConsoleCount() + 1; i++)
            {
                int expected = viewModel.ItemLists.CurrConsole + 1;
                if (expected > viewModel.ItemLists.GetConsoleCount() - 1)
                {
                    expected = viewModel.ItemLists.GetConsoleCount() - 1;
                }
                this.eventAggregator.GetEvent<PubSubEvent<ViewEventArgs>>().Publish(moveRightEventArgs);

                int actual = viewModel.ItemLists.CurrConsole;

                Assert.IsTrue(expected == actual, "Move Right failed. Expected: " + expected + " Actual: " + actual);
            }
        }
        public void Test_ToggleFilter()
        {
            ViewEventArgs filterEventArgs = new ViewEventArgs("TOGGLE_FILTER", new string[] { });
            ItemListViewModel viewModel = new ItemListViewModel(eventAggregator);

            for (int i = 1; i <= 10; i++)
            {
                Visibility expected;
                if (viewModel.FilterVisibility == Visibility.Hidden)
                {
                    expected = Visibility.Visible;
                }
                else
                {
                    expected = Visibility.Hidden;
                }

                this.eventAggregator.GetEvent<PubSubEvent<ViewEventArgs>>().Publish(filterEventArgs);

                Visibility actual = viewModel.FilterVisibility;

                Assert.IsTrue(expected == actual, "Toggle filter failed. Expected: " + expected + " Actual: " + actual);
            }
        }