Exemplo n.º 1
0
        public void WithBookTest()
        {
            using (LibraryDb db = LibraryDb.GetDbContext())
            {
                BOOK book = new BOOK {
                    ISBN = "test", COUNT = 0, NAME = "test", PRICE = 0
                };

                using (DbManager <BOOK> manager = new DbManager <BOOK>(new ManagerBook(), book))
                {
                    manager.AddNewRow();
                    BOOK dbBook = db.BOOKS.SingleOrDefault(b => b.ID == book.ID);
                    Assert.IsNotNull(dbBook);

                    //Change book test
                    dbBook.DESCRIPTION = someText;
                    manager.Entity     = dbBook;
                    manager.UpdateRow();
                    dbBook = db.BOOKS.SingleOrDefault(b => b.ID == book.ID);
                    Assert.AreEqual(true, dbBook?.DESCRIPTION == someText);

                    //deleted test book
                    manager.RemoveRow();
                    dbBook = db.BOOKS.SingleOrDefault(b => b.ID == book.ID);
                    Assert.IsNull(dbBook);
                }
            }
        }
Exemplo n.º 2
0
        public void WithViewerTest()
        {
            using (LibraryDb db = LibraryDb.GetDbContext())
            {
                VIEWER viewer = new VIEWER {
                    ADDRESS = "test", EMAIL = "*****@*****.**", NAME = "test", PHONE = "testtest"
                };

                using (DbManager <VIEWER> manager = new DbManager <VIEWER>(new ManagerViewer(), viewer))
                {
                    //add viewer test
                    manager.AddNewRow();
                    VIEWER dbViewer = db.VIEWERS.SingleOrDefault(v => v.ID == viewer.ID);
                    Assert.IsNotNull(dbViewer);

                    //Change VIEWER test
                    dbViewer.MIDDLE_NAME = someText;
                    manager.Entity       = dbViewer;
                    manager.UpdateRow();
                    dbViewer = db.VIEWERS.SingleOrDefault(b => b.ID == viewer.ID);
                    Assert.AreEqual(true, dbViewer?.MIDDLE_NAME == someText);

                    //deleted test VIEWER
                    manager.RemoveRow();
                    dbViewer = db.VIEWERS.SingleOrDefault(b => b.ID == viewer.ID);
                    Assert.IsNull(dbViewer);
                }
            }
        }
Exemplo n.º 3
0
        private void BtnAddedViewer_OnClick(object sender, RoutedEventArgs e)
        {
            try
            {
                Logger.Info("Getting started: BtnAddedViewer_OnClick");
                VIEWER viewer = GetWindowFields();

                ThreadPool.QueueUserWorkItem(obj =>
                {
                    Manager.Entity = viewer;

                    Manager.AddNewRow();

                    if (Manager.IsOk)
                    {
                        this.GuiSync(Close);
                    }
                });
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                MessageBox.Show(ex.Message, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }