public void Quick_search()
        {
            var term = session.Query <Catalog>().First(c => c.HaveOffers).FullName.Substring(0, 1);

            WpfTestHelper.WithWindow2(async w => {
                var model = new CatalogViewModel();
                var view  = Bind(model);
                w.Content = view;

                await view.WaitLoaded();

                var searchCheck       = view.Descendants <CheckBox>().First(c => c.Name == "CatalogSearch");
                searchCheck.IsChecked = true;
                await view.WaitIdle();
                scheduler.Start();

                var grid = view.Descendants <DataGrid>().First(g => g.Name == "Items");
                grid.SendText(term);
                var search = view.Descendants <TextBox>().First(b => b.Name == "SearchText");
                Assert.IsTrue(search.IsVisible);
                Assert.AreEqual(term, search.Text);
                search.Text = "";

                var enable       = view.Descendants <CheckBox>().First(c => c.Name == "IsQuickSearchEnabled");
                enable.IsChecked = true;

                grid.SendText(term);
                Assert.AreEqual("", search.Text);
                var quicksearch = view.Descendants <ContentControl>().First(c => c.Name == "QuickSearch")
                                  .Descendants <TextBox>().First(c => c.Name == "SearchText");
                Assert.AreEqual(term, quicksearch.Text, quicksearch.GetHashCode().ToString());
            });
        }
示例#2
0
        public void TestMethod1()
        {
            var t = new Test {
                FirstName = "John", LastName = "Doe"
            };
            PersonView v = new PersonView();

            WpfTestHelper.SetupDataContext(v, t);


            //v._firstName.DataContext = t;
            //v._lastName.DataContext = t;
            v._firstName.SetBinding(TextBox.TextProperty, new Binding("FirstName")
            {
                Mode = BindingMode.TwoWay
            });
            v._lastName.SetBinding(TextBox.TextProperty, "LastName");

            Assert.AreEqual("John", v._firstName.Text);
            Assert.AreEqual("Doe", v._lastName.Text);


            //v._firstName.SelectAll();
            //v._firstName.SelectedText = "Karl";
            v._firstName.Text = "Karl";
            WpfTestHelper.UpdateSource(v, TextBox.TextProperty);
            Assert.AreEqual("Karl", t.FirstName);

            //t.FirstName = "Daniel";
            //t.LastName = "Berghold";

            //Assert.AreEqual("Daniel", v._firstName.Text);
            //Assert.AreEqual("Berghold", v._lastName.Text);
        }
示例#3
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);
            });
        }
        public void Revert_value_on_incorrect_input()
        {
            var waybill = new Waybill(new Address("тест"), new Supplier());
            var line    = new WaybillLine(waybill);

            line.RetailCost = 150;
            waybill.AddLine(line);
            WpfTestHelper.WithWindow2(async w => {
                var grid                 = new DataGrid2();
                grid.IsReadOnly          = false;
                grid.AutoGenerateColumns = false;
                grid.Columns.Add(new DataGridTextColumnEx {
                    Binding = new Binding("Product")
                });
                grid.Columns.Add(new DataGridTextColumnEx {
                    Binding = new Binding("RetailCost")
                });
                w.Content        = grid;
                grid.ItemsSource = waybill.Lines;
                await w.WaitIdle();
                var cell = grid.Descendants <DataGridCell>()
                           .First(x => x.Column == grid.Columns[1] && x.DataContext == line);
                Assert.IsTrue(cell.Focus());
                cell.SendKey(Key.F2);
                Assert.IsTrue(cell.IsEditing);
                var input = cell.Descendants <TextBox>().First();
                input.SendText("asd");
                grid.SendKey(Key.Down);
                Assert.IsFalse(cell.IsEditing);
                Assert.AreEqual(150, line.RetailCost);
            });
        }
        public void Style_fixture()
        {
            var offers = new List <Offer>();

            offers.Add(new Offer(new Price("тест"), 100)
            {
                IsGrouped        = true,
                BuyingMatrixType = BuyingMatrixStatus.Denied,
            });

            WpfTestHelper.WithWindow2(async w => {
                var resources = new ResourceDictionary();
                StyleHelper.Reset();
                StyleHelper.BuildStyles(resources);
                var grid = new DataGrid2();
                grid.AutoGenerateColumns = false;
                grid.Columns.Add(new DataGridTextColumn {
                    Binding = new Binding("ProductSynonym")
                });
                grid.Columns.Add(new DataGridTextColumn {
                    Binding = new Binding("OrderCount")
                });
                w.Content = grid;
                StyleHelper.ApplyStyles(typeof(Offer), grid, resources);
                grid.ItemsSource = offers;
                await w.WaitIdle();
                var cells = grid.Descendants <DataGridCell>().ToArray();
                Assert.That(cells.Length, Is.GreaterThan(0));
                foreach (var cell in cells)
                {
                    Assert.AreEqual("#FFFF0000", cell.Background.ToString(), ((TextBlock)cell.Content).Text);
                }
            });
        }
        public void Scroll_on_wheel()
        {
            var items = Enumerable.Range(1, 100).Select(i => Tuple.Create(i.ToString())).ToList();

            WpfTestHelper.WithWindow2(async w => {
                var grid = new DataGrid2();
                grid.AutoGenerateColumns = false;
                grid.Columns.Add(new DataGridTextColumn {
                    Binding = new Binding("Item1")
                });
                w.Content = grid;

                grid.RaiseEvent(new MouseWheelEventArgs(System.Windows.Input.Mouse.PrimaryDevice,
                                                        0,
                                                        -System.Windows.Input.Mouse.MouseWheelDeltaForOneLine)
                {
                    RoutedEvent = UIElement.PreviewMouseWheelEvent,
                    Source      = grid,
                });
                grid.ItemsSource = items;
                await grid.WaitIdle();
                grid.CurrentItem   = items[0];
                grid.CurrentColumn = grid.Columns[0];
                grid.RaiseEvent(new MouseWheelEventArgs(System.Windows.Input.Mouse.PrimaryDevice,
                                                        0,
                                                        -System.Windows.Input.Mouse.MouseWheelDeltaForOneLine)
                {
                    RoutedEvent = UIElement.PreviewMouseWheelEvent,
                    Source      = grid,
                });
                Assert.AreEqual("2", ((Tuple <string>)grid.CurrentItem).Item1);

                await w.WaitIdle();
            });
        }
示例#7
0
        public void Auto_edit()
        {
            var waybill = Fixture <LocalWaybill>().Waybill;

            WpfTestHelper.WithWindow2(async w => {
                var model = new WaybillDetails(waybill.Id);
                var view  = (WaybillDetailsView)Bind(model);
                w.Content = view;

                var grid = view.Descendants <DataGrid>().First(g => g.Name == "Lines");
                await grid.WaitLoaded();
                Assert.IsNotNull(grid.CellStyle);

                grid.SelectedItem = waybill.Lines[0];
                grid.RaiseEvent(WpfTestHelper.TextArgs("1"));
                var column = grid.Columns.First(c => c.Header is TextBlock && ((TextBlock)c.Header).Text.Equals("Розничная наценка"));
                var cell   = DataGridHelper.GetCell(
                    (DataGridRow)grid.ItemContainerGenerator.ContainerFromItem(grid.CurrentCell.Item),
                    column,
                    grid.Columns);
                Assert.IsTrue(cell.IsEditing);
                Assert.AreEqual("1", ((TextBox)cell.Content).Text);
            });

            WpfTestHelper.CleanSafeError();
        }
        public void Do_not_duplicate_result_subscriptions()
        {
            var shell = new Conductor <IScreen>();
            var model = new TestScreen();

            Init(model);

            WpfTestHelper.WithWindow2(async w => {
                var view = (FrameworkElement)ViewLocator.LocateForModel(shell, null, null);
                ViewModelBinder.Bind(shell, view, null);

                w.Content        = view;
                shell.ActiveItem = model;
                await view.WaitLoaded();

                shell.DeactivateItem(model, false);
                await w.WaitIdle();

                shell.ActivateItem(model);
                await w.WaitIdle();

                model.Raise();
                await w.WaitIdle();
            });

            Assert.AreEqual(1, model.ProcessedCount);
        }
示例#9
0
        public void Check_add_from_catalog_enabling()
        {
            user.IsStockEnabled = true;
            session.Save(user);
            var waybill = new Waybill(address, session.Query <Supplier>().First());

            waybill.IsCreatedByUser = true;
            var line = new WaybillLine(waybill)
            {
                Quantity = 1
            };

            waybill.Lines.Add(line);
            session.Save(waybill);

            WpfTestHelper.WithWindow2(async w => {
                var model = new WaybillDetails(waybill.Id);
                var view  = (WaybillDetailsView)Bind(model);
                w.Content = view;

                await view.WaitLoaded();
                var addButton = view.Descendants <Button>().First(b => b.Name == "AddFromCatalog");
                Assert.IsTrue(addButton.Visibility == Visibility.Visible);
                Assert.IsTrue(addButton.IsEnabled);

                view.Descendants <Button>().First(b => b.Name == "Stock")
                .RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent));
                Assert.IsTrue(addButton.Visibility == Visibility.Visible);
                Assert.IsFalse(addButton.IsEnabled);
            });
            WpfTestHelper.CleanSafeError();
        }
示例#10
0
        public void Setup()
        {
            _view = new PersonView();
            _vm   = SampleDataFactory.CreatePersonVM();

            WpfTestHelper.SetupDataContext(_view, _vm);
            SetupBinding();
        }
 public void Popup_scroll()
 {
     WpfTestHelper.WithWindow2(async w => {
         var selector = InitSelector(w);
         await selector.WaitLoaded();
         selector.IsOpened = true;
         await w.WaitIdle();
         var scrollViewer = selector.Descendants <ScrollViewer>().First();
         Assert.AreEqual(Visibility.Visible, scrollViewer.ComputedVerticalScrollBarVisibility);
     });
 }
        public void Filter_label()
        {
            WpfTestHelper.WithWindow2(async w => {
                var selector = InitSelector(w);
                await selector.WaitLoaded();

                var stackPanel = selector.Descendants <Grid>().FirstOrDefault(g => g.Name == "MainGrid").Descendants <StackPanel>().First();
                Assert.That(stackPanel.AsText(), Is.Not.StringContaining(", фильтр применен"));
                selector.IsOpened = true;
                ((ISelectable)selector.Items[0]).IsSelected = false;
                Assert.That(stackPanel.AsText(), Does.Contain(", фильтр применен"));
            });
        }
        public void Search_in_catalog_names()
        {
            shell.ActiveItem             = catalogModel;
            nameViewModel.CurrentCatalog = nameViewModel.Catalogs.Value.First();
            nameViewModel.EnterCatalog();

            var offer = (CatalogOfferViewModel)shell.ActiveItem;

            offer.SearchInCatalog(null, WpfTestHelper.TextArgs("а"));
            Assert.That(shell.ActiveItem, Is.InstanceOf <CatalogViewModel>());
            Assert.That(catalogModel.SearchText, Is.EqualTo("а"));
            Assert.That(catalogModel.CurrentCatalogName.Name.ToLower(), Is.StringStarting("а"));
        }
示例#14
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);
        }
        public void Set_focus_on_empty_grid()
        {
            WpfTestHelper.WithWindow2(async w => {
                var grid  = new DataGrid2();
                w.Content = grid;
                await grid.WaitLoaded();

                Assert.IsFalse(grid.IsKeyboardFocusWithin);
                var point = grid.PointToScreen(new Point(3, 3));
                Mouse.MoveTo(new System.Drawing.Point((int)point.X, (int)point.Y));
                Mouse.Click(MouseButton.Left);
                await w.WaitIdle();
                Assert.IsTrue(grid.IsKeyboardFocusWithin);
            });
        }
示例#16
0
        public void Export()
        {
            var catalog = session.Query <Catalog>().First(c => c.HaveOffers);
            var model   = new CatalogOfferViewModel(catalog);

            WpfTestHelper.WithWindow2(async w => {
                var view  = Bind(model);
                w.Content = view;
                await view.WaitLoaded();

                Assert.IsTrue(model.CanExport.Value);
                result = (OpenResult)model.Export();
                Assert.That(File.Exists(result.Filename), result.Filename);
            });
        }
        public void Focus_on_empty_data_grid()
        {
            WpfTestHelper.WithWindow2(async w => {
                var grid = new DataGrid2();
                grid.AutoGenerateColumns = false;
                grid.Columns.Add(new DataGridTextColumn {
                    Binding = new Binding("Items")
                });
                w.Content        = grid;
                grid.ItemsSource = Enumerable.Empty <Tuple <string> >().ToList();

                await w.WaitIdle();
                DataGridHelper.Focus(grid);
                Assert.IsTrue(grid.IsKeyboardFocusWithin);
            });
        }
        public void Popup_selector()
        {
            WpfTestHelper.WithWindow(w => {
                var selector     = new PopupSelector();
                selector.Name    = "Items";
                selector.Member  = "Item.Item2";
                w.Content        = selector;
                selector.Loaded += (sender, args) => {
                    var text = selector.AsText();
                    Assert.That(text, Does.Contain("test2"));

                    WpfTestHelper.Shutdown(w);
                };
                w.DataContext = new Model();
                ViewModelBinder.Bind(w.DataContext, w, null);
            });
        }
        public void Convert_text()
        {
            var text  = @"Предложения по данным позициям из заказа отсутствуют
адрес доставки тестовый адрес доставки 27131
    прайс-лист Тестовый поставщик минимальный заказ 17948
        АМИНАЗИН р-р д/ин. (амп.) 2.5% - 1 мл N10 - CANPOL 385882399: имеется различие в цене препарата (старая цена: 5 155,25р.; новая цена: 3 803,59р.)
        АЛКЕРАН лиоф. пор. д/ин. (амп.) 50 мг N1 - CANPOL 272172924: имеется различие в цене препарата (старая цена: 1 963,27р.; новая цена: 7 846,26р.)
        АМИНАЗИН р-р д/ин. (амп.) 2.5% - 1 мл N10 1362470529 - CANPOL 2032824958: имеется различие в цене препарата (старая цена: 5 215,45р.; новая цена: 8 891,76р.)
        АЛКЕРАН лиоф. пор. д/ин. (амп.) 50 мг N1 795399701 - CANPOL 1413518865: имеется различие в цене препарата (старая цена: 5 211,38р.; новая цена: 6 772,29р.)
        АЛКА-ЗЕЛЬТЦЕР табл. шип. N10 - CANPOL 812196717: имеется различие в цене препарата (старая цена: 3 806,94р.; новая цена: 1 724,41р.)
        АЛКЕРАН табл. 2 мг N25 - CANPOL 814314867: имеется различие в цене препарата (старая цена: 4 155,58р.; новая цена: 5 851,08р.)
        АЛЛЕРГЕНЫ ПЫЛЬЦЕВЫЕ в комплектах - CANPOL 905024831: имеется различие в цене препарата (старая цена: 456,32р.; новая цена: 7 283,92р.)";
            var model = new TextDoc("тест", text);
            var doc   = model.ToFlowDocument();

            Assert.That(WpfTestHelper.FlowDocumentToText(doc), Does.Contain("АЛЛЕРГЕНЫ ПЫЛЬЦЕВЫЕ"));
        }
 public void Do_not_reset_data_grid_focus()
 {
     WpfTestHelper.WithWindow2(async w => {
         var grid = new DataGrid2();
         grid.AutoGenerateColumns = false;
         grid.Columns.Add(new DataGridTextColumn {
             Binding = new Binding("Items")
         });
         w.Content        = grid;
         grid.ItemsSource = Enumerable.Range(1, 100).Select(i => Tuple.Create(i.ToString())).ToList();
         await grid.WaitLoaded();
         DataGridHelper.Focus(grid);
         grid.ItemsSource = Enumerable.Range(500, 100).Select(i => Tuple.Create(i.ToString())).ToList();
         await w.WaitIdle();
         Assert.IsTrue(grid.IsKeyboardFocusWithin);
         Assert.IsInstanceOf <DataGridCell>(Keyboard.FocusedElement);
     });
 }
示例#21
0
        public void Show_print_for_created_waybill()
        {
            var waybill = new Waybill(session.Query <Address>().First(), session.Query <Supplier>().First());

            waybill.IsCreatedByUser = true;
            session.Save(waybill);

            WpfTestHelper.WithWindow2(async w => {
                var model = new WaybillDetails(waybill.Id);
                var view  = (WaybillDetailsView)Bind(model);
                w.Content = view;

                await view.WaitLoaded();
                view.Descendants <Button>().First(b => b.Name == "PrintWaybill")
                .RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent));
            });
            WpfTestHelper.CleanSafeError();
        }
示例#22
0
        public void Show_address()
        {
            restore = true;
            session.Save(new Address("Тестовый адрес доставки"));
            session.DeleteEach <BatchLine>();
            session.Save(new BatchLine(session.Query <Catalog>().First(), address)
            {
                Comment    = "test comment",
                Properties = "Клубничный",
            });

            WpfTestHelper.WithWindow2(async w => {
                var model = new Batch();
                var view  = Bind(model);
                w.Content = view;

                await view.WaitLoaded();

                var searchCheck       = view.Descendants <CheckBox>().First(c => c.Name == "All");
                searchCheck.IsChecked = true;

                var grid = view.Descendants <DataGrid>().First(c => c.Name == "ReportLines");
                scheduler.Start();
                grid.CurrentItem = grid.Items[0];
                await view.WaitIdle();

                var col = DataGridHelper.FindColumn(grid, "Адрес заказа");
                Assert.AreEqual(col.Visibility, Visibility.Visible);
                var comment = view.Descendants <TextBox>().First(c => c.Name == "CurrentReportLine_Value_Comment");
                Assert.AreEqual("test comment", comment.Text);

                col            = DataGridHelper.FindColumn(grid, "Кат.свойства");
                col.Visibility = Visibility.Visible;
                await view.WaitIdle();
                var cell = grid.Descendants <DataGridCell>().First(x => x.Column == col);
                Assert.AreEqual("Клубничный", cell.Descendants <TextBlock>().First().Text);
            });
        }
示例#23
0
        public void Spliter_settings()
        {
            var expected = new GridLength();
            int diff;

            WpfTestHelper.WithWindow2(async w => {
                var model = new MinCosts();
                var view  = Bind(model);
                w.Content = view;
                await view.WaitLoaded();
                var grid   = (Grid)view.FindName("MainGrid");
                var row    = grid.RowDefinitions[Grid.GetRow((UIElement)view.FindName("Costs"))];
                row.Height = new GridLength(row.ActualHeight - 5, GridUnitType.Pixel);
                expected   = row.Height;

                diff = model.Diff.Value = model.Diff.Value + 1;
                Close(model);
            });

            var memory       = new MemoryStream();
            var streamWriter = new StreamWriter(memory);

            shell.Serialize(streamWriter);
            streamWriter.Flush();
            shell.PersistentContext.Clear();
            memory.Position = 0;
            shell.Deserialize(new StreamReader(memory));

            WpfTestHelper.WithWindow2(async w => {
                var view  = Bind(new MinCosts());
                w.Content = view;
                var grid  = (Grid)view.FindName("MainGrid");
                await view.WaitLoaded();
                var actual = grid.RowDefinitions[Grid.GetRow((UIElement)view.FindName("Costs"))].Height;
                Assert.AreEqual(expected.GridUnitType, actual.GridUnitType);
                Assert.AreEqual(expected.Value, actual.Value, 0.001);
            });
        }
示例#24
0
        public void Commit_edit()
        {
            var scheduler = new TestScheduler();
            var viewModel = new ViewModel();
            var items     = new List <Item> {
                new Item()
            };

            var grid = new DataGrid2();

            grid.DataContext  = viewModel;
            grid.ItemsSource  = items;
            grid.SelectedItem = items[0];
            new Editable(scheduler).Attach(grid);
            grid.RaiseEvent(WpfTestHelper.TextArgs("1"));

            Assert.IsTrue(viewModel.updated);
            Assert.IsFalse(viewModel.commited);

            scheduler.AdvanceByMs(2000);
            Assert.IsTrue(viewModel.commited);
            Assert.AreEqual(1, items[0].Value);
        }
        public void Searchable_column()
        {
            WpfTestHelper.WithWindow2(async w => {
                var model        = new SearchableModel();
                var grid         = new DataGrid2();
                grid.DataContext = model;
                BindingOperations.SetBinding(grid, DataGrid.ItemsSourceProperty, new Binding("Items.Value"));
                BindingOperations.SetBinding(grid, SearchableDataGridColumn.SearchTermProperty, new Binding("Term.Value"));
                grid.AutoGenerateColumns = false;
                grid.Columns.Add(new SearchableDataGridColumn {
                    Binding        = new Binding("Item1"),
                    HighlightStyle = new Style {
                        Setters =
                        {
                            new Setter(TextElement.BackgroundProperty, Brushes.Red)
                        }
                    }
                });
                w.Content = grid;
                await grid.WaitLoaded();
                await w.WaitIdle();

                model.Items.Value = Enumerable.Range(0, 49).Select(i => Tuple.Create(i.ToString())).ToList();
                await w.WaitIdle();

                model.Term.Value  = "5";
                model.Items.Value = Enumerable.Range(50, 100).Select(i => Tuple.Create(i.ToString())).ToList();
                await w.WaitIdle();

                var row  = grid.Descendants <DataGridRow>().First(r => ((Tuple <String>)r.DataContext).Item1 == "50");
                var text = row.Descendants <TextBlock>().First();
                Assert.AreEqual("50", text.Text);
                var inlines = text.Inlines.OfType <Run>().ToArray();
                Assert.AreEqual("5", inlines[0].Text);
                Assert.AreEqual("0", inlines[1].Text);
            });
        }
        public void Mark_search_results()
        {
            WpfTestHelper.WithWindow2(async w => {
                var model = new CatalogViewModel();
                var view  = Bind(model);
                w.Content = view;

                await view.WaitLoaded();

                var searchCheck       = view.Descendants <CheckBox>().First(c => c.Name == "CatalogSearch");
                searchCheck.IsChecked = true;
                await view.WaitIdle();

                var allCheck       = view.Descendants <CheckBox>().First(c => c.Name == "ShowWithoutOffers");
                allCheck.IsChecked = true;
                await view.WaitIdle();

                var search  = view.Descendants <TextBox>().First(b => b.Name == "SearchText");
                search.Text = "мыло";
                var grid    = view.Descendants <DataGrid>().First(g => g.Name == "Items");
                grid.SendKey(Key.Return);
                await view.WaitIdle();
            });
        }
 public void Get_cell()
 {
     WpfTestHelper.WithWindow2(async w => {
         var grid = new DataGrid {
             Columns =
             {
                 new DataGridTextColumn {
                     DisplayIndex = 1
                 },
                 new DataGridTextColumn {
                     DisplayIndex = 0
                 }
             },
             ItemsSource = new[] { 1, 2 }
         };
         grid.CurrentItem = grid.Items[0];
         grid.CurrentCell = new DataGridCellInfo(grid.CurrentItem, grid.Columns[1]);
         w.Content        = grid;
         await grid.WaitLoaded();
         var cell = DataGridHelper.GetCell(grid, grid.CurrentCell);
         Assert.AreEqual(grid.CurrentItem, cell.DataContext);
         Assert.AreEqual(grid.Columns[1], cell.Column);
     });
 }
        public void Do_not_lose_focus_on_delete()
        {
            var items = Enumerable.Range(1, 100).Select(i => Tuple.Create(i.ToString())).ToList();
            var data  = new ObservableCollection <Tuple <String> >(items);

            WpfTestHelper.WithWindow2(async w => {
                var grid = new DataGrid2();
                grid.AutoGenerateColumns = false;
                grid.Columns.Add(new DataGridTextColumn {
                    Binding = new Binding("Items")
                });
                w.Content        = grid;
                grid.ItemsSource = data;

                await w.WaitIdle();
                DataGridHelper.Focus(grid);
                Assert.IsNotNull(grid.CurrentItem);
                data.Remove((Tuple <string>)grid.SelectedItem);

                await w.WaitIdle();
                Assert.IsTrue(grid.IsKeyboardFocusWithin);
                Assert.IsNotNull(grid.CurrentItem);
            });
        }