コード例 #1
0
        public void ChangeStockTypeProperty()
        {
            var viewmodel = SelectSomeTreeViewNode();

            var inc = viewmodel.DataGridViewModel.Items.Where(x => x.StockType == IOStockType.INCOMING);
            var item = viewmodel.DataGridViewModel.Items.Where(x => x.StockType == IOStockType.INCOMING).Random();
            var mvm = new IOStockManagerViewModel(viewmodel, item);
            mvm.StockType = IOStockType.OUTGOING;
            mvm.Update();
            AssertQuantityChecking(viewmodel.DataGridViewModel.Items);
        }
コード例 #2
0
        public void TestInit0()
        {
            var inv = DataDirector.GetInstance().CopyInventories().Random();
            var qret = DataDirector.GetInstance().DB.Query<IOStockFormat>("select * from IOStockFormat where InventoryID = '{0}' and StockType = 1 limit 1;", inv.ID);
            var ios = new ObservableIOStock(qret.Random());
            var vm = new IOStockManagerViewModel(ios);

            Assert.AreEqual(vm.SelectedAccount, ios.Supplier);
            Assert.AreEqual(vm.SelectedProject, ios.Warehouse);
            Assert.AreEqual(vm.SelectedEmployee, ios.Employee);
            Assert.AreEqual(vm.Memo, ios.Memo);
            Assert.AreEqual(vm.Quantity, ios.Quantity);
            Assert.AreEqual(vm.SelectedDate, ios.Date);
            Assert.AreEqual(vm.SelectedInventory, ios.Inventory);
            Assert.AreEqual(vm.UnitPrice, ios.UnitPrice);
        }
コード例 #3
0
        public void ChangeDateTimeProperty()
        {
            var viewmodel = SelectSomeTreeViewNode();

            var item = viewmodel.DataGridViewModel.Items.Random();
            var mvm = new IOStockManagerViewModel(viewmodel, item);
            mvm.SelectedDate = DateTime.Now;
            mvm.Update();

            AssertQuantityChecking(viewmodel.DataGridViewModel.Items);
        }
コード例 #4
0
        public void UnitPriceAndAccountQueryTest1()
        {
            DataDirector ddr = DataDirector.GetInstance();
            Observable<Product> prod = ddr.CopyFields<Product>().Random();
            IOStockManagerViewModel vm = new IOStockManagerViewModel(prod);

            Assert.AreEqual(0, vm.UnitPrice);

            vm.SelectedInventory = vm.Inventories.Random();

            Assert.AreNotEqual(0, vm.UnitPrice);
        }
コード例 #5
0
        public void UnitPriceAndAccountQueryTest3()
        {
            ObservableInventory inv = DataDirector.GetInstance().CopyInventories().Random();
            IOStockManagerViewModel vm = new IOStockManagerViewModel(inv);
            decimal price = vm.UnitPrice;
            vm.StockType = IOStockType.OUTGOING;
            price = vm.UnitPrice = price + 1000;
            var supplier = vm.SelectedAccount = vm.Accounts.Random();
            vm.Insert();

            vm = new IOStockManagerViewModel(inv);
            vm.StockType = IOStockType.OUTGOING;
            Assert.AreEqual(price, vm.UnitPrice);
            Assert.AreEqual(supplier, vm.SelectedAccount);
        }
コード例 #6
0
        public void TestIOStockTypeChange3()
        {
            var inv = DataDirector.GetInstance().CopyInventories().Random();
            var qret = DataDirector.GetInstance().DB.Query<IOStockFormat>("select * from IOStockFormat where InventoryID = '{0}' and StockType = 2 limit 1;", inv.ID);
            var oios = new ObservableIOStock(qret.Random());
            var vm = new IOStockManagerViewModel(oios);

            vm.StockType = IOStockType.INCOMING;

            Assert.AreEqual(null, vm.SelectedAccount);
            Assert.AreEqual(null, vm.SelectedProject);
        }
コード例 #7
0
        public void UnitPriceAndAccountQueryTest0()
        {
            DataDirector ddr = DataDirector.GetInstance();
            Observable<Product> prod = ddr.CopyFields<Product>().Random();
            InventoryFormat invf = new InventoryFormat() { ProductID = prod.ID, Specification = "some"};
            
            ddr.AddInventory(invf);

            ObservableInventory inv = DataDirector.GetInstance().SearchInventory(invf.ID);

            IOStockManagerViewModel vm = new IOStockManagerViewModel(inv);
            Assert.AreEqual(0, vm.UnitPrice); //입고 출고에 아무런 데이터가 없어서 자동적으로 0으로 초기화

            decimal price = vm.UnitPrice = 1500;
            vm.Insert(); //입고 넣기

            vm = new IOStockManagerViewModel(inv);
            Assert.AreEqual(price, vm.UnitPrice); //입고에 있는 값 불러옴

            vm.StockType = IOStockType.OUTGOING;
            Assert.AreEqual(price, vm.UnitPrice); //출고지만 자료가 없어 입고 값으로 덮씌움
            price = vm.UnitPrice = 1700;

            vm.Insert(); //출고 넣기

            vm = new IOStockManagerViewModel(inv);
            vm.StockType = IOStockType.OUTGOING;
            Assert.AreEqual(price, vm.UnitPrice); //출고의 UnitPrice 가져옴
            Assert.IsNull(vm.SelectedAccount);
        }
コード例 #8
0
        public void ModifyIOStockFormat3()
        {
            var inv = DataDirector.GetInstance().CopyInventories().Random();
            var qret = DataDirector.GetInstance().DB.Query<IOStockFormat>("select * from IOStockFormat where InventoryID = '{0}' and StockType = 2 limit 1;", inv.ID);
            var oios = new ObservableIOStock(qret.Random());
            var vm = new IOStockManagerViewModel(oios);

            string name = "new";
            vm.SelectedAccount = null;
            vm.SelectedProject = null;
            vm.SelectedEmployee = null;
            vm.AccountText = name;
            vm.ProjectText = name;
            vm.EmployeeText = name;

            ObservableIOStock oio = vm.Update();

            Assert.AreEqual(name, oio.Customer.Name);
            Assert.AreEqual(name, oio.Employee.Name);
            Assert.AreEqual(name, oio.Project.Name);
        }
コード例 #9
0
        public void WhenModifyQtyThenSyncDataGridViewItems()
        {
            ObservableInventory inv = DataDirector.GetInstance().CopyInventories().Random();
            IOStockFormat qret = DataDirector.GetInstance().DB.Query<IOStockFormat>("select * from IOStockFormat where InventoryID = '{0}' and StockType = 2 limit 1;", inv.ID).Single();

            IOStockStatusViewModel svm = new IOStockStatusViewModel();

            svm.SelectedDataGridGroupOption = IOStockStatusViewModel.DATAGRID_OPTION_PRODUCT;
            List<TreeViewNode> nodes = svm.TreeViewViewModel.SearchNodesInRoot(NodeType.INVENTORY);
            TreeViewNode node = nodes.Where(x => x.ObservableObjectID == qret.InventoryID).Single();
            svm.TreeViewViewModel.AddSelectedNodes(node);

            IOStockDataGridItem stock = DataDirector.GetInstance().StockCollection.Where(x => x.ID == qret.ID).Single();

            IOStockManagerViewModel vm = new IOStockManagerViewModel(stock);
            int qty = vm.Quantity = 10;
            vm.Update();

            ObservableCollection<IOStockDataGridItem> items = svm.DataGridViewModel.Items;
            IOStockDataGridItem result = items.Where(x => x.ID == stock.ID).Single();

            Assert.AreEqual(result, stock);
            Assert.AreEqual(qty, result.Quantity);
        }
コード例 #10
0
        public void ModifyIOStockFormat1()
        {
            var inv = DataDirector.GetInstance().CopyInventories().Random();
            var qret = DataDirector.GetInstance().DB.Query<IOStockFormat>("select * from IOStockFormat where InventoryID = '{0}' and StockType = 1 limit 1;", inv.ID);
            var oios = new ObservableIOStock(qret.Random());
            var vm = new IOStockManagerViewModel(oios);

            vm.SelectedAccount = vm.Accounts.Random();
            vm.SelectedEmployee = vm.Employees.Random();
            vm.SelectedProject = vm.Projects.Random();

            ObservableIOStock oio = vm.Update();

            Assert.AreEqual(vm.SelectedAccount, oio.Supplier);
            Assert.AreEqual(vm.SelectedEmployee, oio.Employee);
            Assert.AreEqual(vm.SelectedProject, oio.Warehouse);
        }
コード例 #11
0
        public void ModifyIOStockFormat2()
        {
            var inv = DataDirector.GetInstance().CopyInventories().Random();
            var qret = DataDirector.GetInstance().DB.Query<IOStockFormat>("select * from IOStockFormat where InventoryID = '{0}' and StockType = 2 limit 1;", inv.ID);
            var oios = new ObservableIOStock(qret.Random());
            var vm = new IOStockManagerViewModel(oios);

            var acc = vm.SelectedAccount = vm.Accounts.Random();
            var emp = vm.SelectedEmployee = vm.Employees.Random();
            var prj = vm.SelectedProject = vm.Projects.Random();

            ObservableIOStock oio = vm.Update();

            Assert.AreEqual(acc, oio.Customer);
            Assert.AreEqual(emp, oio.Employee);
            Assert.AreEqual(prj, oio.Project);
        }
コード例 #12
0
        public void ModifyIOStockFormat0()
        {
            ObservableInventory inv = DataDirector.GetInstance().CopyInventories().Random();
            List<IOStockFormat> qret = DataDirector.GetInstance().DB.Query<IOStockFormat>("select * from IOStockFormat where InventoryID = '{0}' and StockType = 1 limit 1;", inv.ID);
            ObservableIOStock oios = new ObservableIOStock(qret.Random());
            IOStockManagerViewModel vm = new IOStockManagerViewModel(oios);

            var qty = vm.Quantity = 10;
            var pri = vm.UnitPrice = 1000;

            ObservableIOStock oio = vm.Update();

            Assert.AreEqual(qty, oio.Quantity);
            Assert.AreEqual(pri, oio.UnitPrice);
        }
コード例 #13
0
        public void CreateNewIOStock3()
        {
            var prod = DataDirector.GetInstance().CopyFields<Product>().Random();
            var vm = new IOStockManagerViewModel(prod);

            vm.StockType = IOStockType.OUTGOING;
            var inv = vm.SelectedInventory = vm.Inventories.Random();
            vm.SelectedAccount = null;
            var acc = vm.AccountText = "new";
            var eep = vm.EmployeeText = "new";
            var prj = vm.ProjectText = "new";

            ObservableIOStock oio = vm.Insert();

            Assert.AreEqual(inv, oio.Inventory);
            Assert.AreEqual(acc, oio.Customer.Name);
            Assert.AreEqual(eep, oio.Employee.Name);
            Assert.AreEqual(prj, oio.Project.Name);
        }
コード例 #14
0
        public void CreateNewIOStock2()
        {
            var prod = DataDirector.GetInstance().CopyFields<Product>().Random();
            var vm = new IOStockManagerViewModel(prod);

            vm.StockType = IOStockType.OUTGOING;
            vm.SelectedAccount = null;
            var inv = vm.SelectedInventory = vm.Inventories.Random();
            var acc = vm.SelectedAccount = vm.Accounts.Random();
            var eep = vm.SelectedEmployee = vm.Employees.Random();
            var prj = vm.SelectedProject = vm.Projects.Random();
            var mem = vm.Memo = "some memo";

            ObservableIOStock oio = vm.Insert();

            Assert.AreEqual(inv, oio.Inventory);
            Assert.AreEqual(acc, oio.Customer);
            Assert.AreEqual(eep, oio.Employee);
            Assert.AreEqual(prj, oio.Project);
            Assert.AreEqual(mem, oio.Memo);
        }
コード例 #15
0
        public void AddNewStockData()
        {
            IOStockStatusViewModel viewmodel = new IOStockStatusViewModel();
            viewmodel.SelectedDataGridGroupOption = IOStockStatusViewModel.DATAGRID_OPTION_PROJECT;
            Observable<Project> project = viewmodel.ProjectListBoxViewModel.SelectedItem = viewmodel.ProjectListBoxViewModel.Items.Random();

            var mvm = new IOStockManagerViewModel(DataDirector.GetInstance().CopyInventories().Random());
            mvm.Insert();
        }
コード例 #16
0
        public void CreateInventoryThenCreateStock()
        {
            var prod = DataDirector.GetInstance().CopyFields<Product>().Random();
            InventoryFormat inv = new InventoryFormat();
            inv.ProductID = prod.ID;
            inv.ID = Guid.NewGuid().ToString();

            DataDirector.GetInstance().AddInventory(inv);

            var vm = new IOStockManagerViewModel(prod);
            vm.SelectedInventory = vm.Inventories.Random();
            vm.Quantity = 10;
            vm.UnitPrice = 1000;

            vm.Insert();
        }
コード例 #17
0
 public void OpenManager(ObservableIOStock iostock)
 {
     IOStockManagerViewModel viewmodel = new IOStockManagerViewModel(this, iostock);
     IOStockManagerWindow window = new IOStockManagerWindow();
     window.DataContext = viewmodel;
     window.Owner = Application.Current.MainWindow;
     window.ShowDialog();
 }
コード例 #18
0
        public void TestIOStockTypeChange1()
        {
            var prod = DataDirector.GetInstance().CopyFields<Product>().Random();
            var vm = new IOStockManagerViewModel(prod);

            vm.StockType = IOStockType.OUTGOING;
            vm.StockType = IOStockType.INCOMING;
            Assert.AreEqual(vm.Accounts.Random().GetType(), typeof(Observable<Supplier>));
            Assert.AreEqual(vm.Projects.Random().GetType(), typeof(Observable<Warehouse>));
        }