コード例 #1
0
        public void Move_focus()
        {
            WpfTestHelper.WithWindow2(async w => {
                var model = new CatalogViewModel();
                var view  = Bind(model);
                w.Content = view;

                await view.WaitLoaded();
                scheduler.Start();
                await view.WaitIdle();
                var names = view.Descendants <DataGrid2>().First(x => x.Name == "CatalogNames");
                var forms = view.Descendants <DataGrid2>().First(x => x.Name == "Catalogs");
                names.Focus();
                Assert.IsTrue(names.IsKeyboardFocusWithin);
                Assert.IsFalse(forms.IsKeyboardFocusWithin);
                var id = session.Query <CatalogName>()
                         .First(c => c.HaveOffers && session.Query <Catalog>().Count(x => x.HaveOffers && x.Name == c) > 1)
                         .Id;
                names.SelectedItem = names.Items.OfType <CatalogName>().First(x => x.Id == id);
                scheduler.Start();
                names.RaiseEvent(WpfTestHelper.KeyArgs(names, Key.Enter));
                await view.WaitIdle();
                Assert.IsFalse(names.IsKeyboardFocusWithin);
                Assert.IsTrue(forms.IsKeyboardFocusWithin);
            });
        }
コード例 #2
0
        public void Enter_price()
        {
            WpfTestHelper.WithWindow2(async w => {
                var view  = Bind(new PriceViewModel());
                var grid  = (DataGrid)view.FindName("Prices");
                w.Content = view;

                await w.WaitLoaded();
                var keyEventArgs         = WpfTestHelper.KeyArgs(grid, Key.Enter);
                keyEventArgs.RoutedEvent = DataGrid.KeyDownEvent;
                grid.RaiseEvent(keyEventArgs);
            });
            Assert.IsInstanceOf <PriceOfferViewModel>(shell.ActiveItem);
        }