Esempio n. 1
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 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("а"));
        }
Esempio n. 3
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);
        }