public void CanCreate2()
 {
     var inv = DataDirector.GetInstance().CopyInventories().Random();
     var qret = DataDirector.GetInstance().DB.Query<IOStockFormat>("select * from IOStockFormat where InventoryID = '{0}' limit 1;", inv.ID);
     var ios = new ObservableIOStock(qret.Random());
     new IOStockManagerViewModel(ios);
 }
        /// <summary>
        /// 기존의 입출고 데이터를 수정합니다. 이 떄 규격은 변경되지 아니합니다.
        /// </summary>
        /// <param name="stock"></param>
        public IOStockManagerViewModel(ObservableIOStock stock) : this(stock.Inventory.Product.ID)
        {
            _target = stock;
            Title = string.Format("입출고 데이터 편집하기", stock.ID);
            IsEnabledRadioButton = true;
            IsEnabledInventoryComboBox = false;

            Quantity = stock.Quantity;
            UnitPrice = stock.UnitPrice;
            SelectedEmployee = stock.Employee;
            Memo = stock.Memo;
            SelectedDate = stock.Date;
            SelectedInventory = stock.Inventory as ObservableInventory;
            StockType = stock.StockType;

            switch (StockType)
            {
                case IOStockType.INCOMING:
                    SelectedAccount = stock.Supplier;
                    SelectedProject = stock.Warehouse;
                    break;
                case IOStockType.OUTGOING:
                    SelectedAccount = stock.Customer;
                    SelectedProject = stock.Project;
                    break;
            }
        }
        public void Quantity5()
        {
            new Dummy().Create();
            IOStockFormat fmt = null;
            IEnumerable<IOStockFormat> formats;
            var inventory = DataDirector.GetInstance().CopyInventories().Random();
            formats = DataDirector.GetInstance().DB.Select<IOStockFormat>().Where(x => x.InventoryID == inventory.ID).OrderBy(x => x.Date)
                .ToList();
            fmt = formats.ElementAt(new Random().Next(0, formats.Count() - 2)); //최신 데이터는 넣지 말도록
            var obIOStock = new ObservableIOStock(fmt);
            int inventoryQty = obIOStock.Inventory.Quantity; //오리진 재고 수량
            IOStockDataAmenderViewModel viewmodel = new IOStockDataAmenderViewModel(obIOStock);

            int ioStockQty = fmt.Quantity; //오리진 입출고 수량

            int changeQty = 1;
            int effectQty = viewmodel.StockType == IOStockType.INCOMING ? changeQty : -changeQty;

            viewmodel.Quantity = ioStockQty + changeQty; //입출고 수량을 하나 증가함
            Assert.AreEqual(viewmodel.InventoryQuantity, inventoryQty + effectQty);
        }
 public void Quantity3()
 {
     new Dummy().Create();
     IOStockStatusViewModel iostockStatusViewModel = new IOStockStatusViewModel();
     IOStockFormat fmt = null;
     fmt = DataDirector.GetInstance().DB.Select<IOStockFormat>().Random();
     IObservableIOStockProperties obIOStock = new ObservableIOStock(fmt);
     var inventoryQty = obIOStock.Inventory.Quantity;
     var viewmodel = new IOStockDataAmenderViewModel(obIOStock);
     viewmodel.Quantity = 12;
     obIOStock = viewmodel.Record();
     CheckQuantity(obIOStock.Inventory as ObservableInventory);
 }
        public void Quantity2()
        {
            new Dummy().Create();
            IOStockFormat fmt = null;
            fmt = DataDirector.GetInstance().DB.Select<IOStockFormat>().Where(x => x.StockType == IOStockType.INCOMING).OrderBy(x => x.Date).Last();

            ///////////////////////////////////////////입고
            fmt.Quantity = 100; //입고 수량
            fmt.RemainingQuantity = 200; //잔여 재고
            var obIOStock = new ObservableIOStock(fmt);
            obIOStock.Inventory.Quantity = 500; //현재 재고
            IOStockDataAmenderViewModel viewmodel = new IOStockDataAmenderViewModel(obIOStock);
            viewmodel.StockType = IOStockType.INCOMING;
            viewmodel.Quantity = 99; //입고수량 하나 줄임
            Assert.AreEqual(499, viewmodel.InventoryQuantity); //따라서 현재 재고도 하나 줄어든다.
            viewmodel.Quantity = 101;
            Assert.AreEqual(501, viewmodel.InventoryQuantity);

            ///////////////////////////////////////////출고
            fmt = DataDirector.GetInstance().DB.Select<IOStockFormat>().Where(x => x.StockType == IOStockType.OUTGOING).OrderBy(x => x.Date).Last();
            fmt.Quantity = 100; //들어간 양
            fmt.RemainingQuantity = 200; //잔여 재고
            obIOStock = new ObservableIOStock(fmt);
            obIOStock.Inventory.Quantity = 500; //현재 재고
            viewmodel = new IOStockDataAmenderViewModel(obIOStock);
            viewmodel.StockType = IOStockType.OUTGOING;
            viewmodel.Quantity = 99; //출고수량 하나 줄임
            Assert.AreEqual(501, viewmodel.InventoryQuantity); //따라서 현재 재고도 하나 늘어난다.
            viewmodel.Quantity = 101;
            Assert.AreEqual(499, viewmodel.InventoryQuantity);
        }
        public void Modify5()
        {
            new Dummy().Create();
            var formats = DataDirector.GetInstance().DB.Select<IOStockFormat>();
            var fmt = formats.Random();
            ObservableIOStock ios = new ObservableIOStock(fmt);
            //DataGrid 업데이트
            IOStockStatusViewModel iosViewModel = new IOStockStatusViewModel();
            TreeViewNode node = TreeViewNodeDirector.GetInstance().SearchObservableObjectNode(ios.Inventory.Product.ID);
            if (node != null)
            {
                MultiSelectTreeViewModelView treeView = iosViewModel.TreeViewViewModel;
                treeView.SelectedNodes.Clear();
                treeView.ExecuteNodesSelectedEventCommand(new SelectionChangedCancelEventArgs(new TreeViewNode[] { node }, null));
            }
            Assert.AreNotEqual(0, iosViewModel.DataGridViewModel.Items.Count);

            IOStockDataAmenderViewModel viewmodel = new IOStockDataAmenderViewModel(); //추가모드로 열기
            viewmodel.Product = ios.Inventory.Product;
            viewmodel.Inventory = viewmodel.InventoryList.Where(x => x.ID == ios.Inventory.ID).Single();
            viewmodel.Maker = null; //null 할당
            viewmodel.Maker = null;

            var newRecord = viewmodel.Record();
            newRecord = iosViewModel.DataGridViewModel.Items.Where(x => x.ID == newRecord.ID).Single();
            Assert.IsNull(newRecord.Inventory.Maker);

            viewmodel = new IOStockDataAmenderViewModel(newRecord); //편집모드로 열기
            Assert.IsNull(viewmodel.Maker);
            viewmodel.MakerText = "maKeR";
            newRecord = viewmodel.Record();

            var jojoEmp = newRecord.Inventory.Maker;
            Assert.IsNotNull(newRecord.Inventory);
            Assert.AreEqual(newRecord.Inventory.Maker.Name, "maKeR");

            Assert.IsNotNull(DataDirector.GetInstance().SearchField<Maker>(newRecord.Inventory.Maker.ID));

            newRecord = iosViewModel.DataGridViewModel.Items.Where(x => x.ID == newRecord.ID).Single();
            viewmodel = new IOStockDataAmenderViewModel(newRecord); //편집모드로 열기
            viewmodel.Maker = null;
            viewmodel.MakerText = "maKeR2";
            var newnewRecord = viewmodel.Record();

            Assert.AreEqual(newnewRecord.Inventory.Maker.Name, "maKeR2");
            Assert.AreEqual(jojoEmp.ID, newRecord.Inventory.Maker.ID);
        }
        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);
        }
        public void WhenModifyThenInventoryIsChildOfInventoryList()
        {
            new Dummy().Create();
            IOStockFormat fmt = null;
            fmt = DataDirector.GetInstance().DB.Select<IOStockFormat>().Random();
            IOStockType type = fmt.StockType;
            var iso = new ObservableIOStock(fmt);
            IOStockDataAmenderViewModel viewmodel = new IOStockDataAmenderViewModel(new ObservableIOStock(fmt));

            Assert.AreEqual(iso.Inventory.Product, viewmodel.Product);
            Assert.IsNotNull(viewmodel.Inventory);
            Assert.IsNotNull(viewmodel.InventoryList);
            Assert.IsTrue(viewmodel.Inventory.ID == iso.Inventory.ID);
            Assert.IsTrue(viewmodel.InventoryList.Any(x => x.ID == viewmodel.Inventory.ID));
            Assert.IsTrue(viewmodel.InventoryList.Contains(viewmodel.Inventory)); //여기서 문제남
        }
 public void CheckQuantity(ObservableInventory inventory)
 {
     string sql = string.Format("select * from {0} where {1} = {2} order by {3}", typeof(IOStockFormat).Name, "InventoryID", nameof(inventory.ID), "Date");
     var formats = DataDirector.GetInstance().DB.Query<IOStockFormat>(sql);
     IOStockFormat near = null;
     foreach (var fmt in formats)
     {
         int remainQty = 0;
         int iosQty = fmt.Quantity;
         if (fmt.StockType == IOStockType.OUTGOING)
             iosQty = -iosQty;
         if (near != null)
             remainQty = near.RemainingQuantity;
         int exp = remainQty + iosQty;
         Assert.AreEqual(fmt.RemainingQuantity, exp);
         near = fmt;
     }
     var last = formats.Last();
     var stock = new ObservableIOStock(last);
     Assert.AreEqual(stock.RemainingQuantity, stock.Inventory.Quantity);
 }
 public IOStockManagerViewModel(IOStockStatusViewModel iOStockStatusViewModel, ObservableIOStock stock)
     : this(stock)
 {
     _iOStockStatusViewModel = iOStockStatusViewModel;
 }
        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);
        }
        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);
        }
        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);
        }
        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);
        }
        public void Quantity6()
        {
            new Dummy().Create();
            IOStockFormat fmt = null;
            IEnumerable<IOStockFormat> formats;
            var inventory = DataDirector.GetInstance().CopyInventories().Random();
            formats = DataDirector.GetInstance().DB.Select<IOStockFormat>().Where(x => x.InventoryID == inventory.ID).OrderBy(x => x.Date)
                .ToList();
            fmt = formats.ElementAt(new Random().Next(0, formats.Count() - 2));

            var iostock = new ObservableIOStock(fmt);
            int inventoryQty = iostock.Inventory.Quantity;
            IOStockDataAmenderViewModel viewmodel = new IOStockDataAmenderViewModel();
            viewmodel.StockType = IOStockType.INCOMING;
            viewmodel.Product = iostock.Inventory.Product;
            viewmodel.Inventory = viewmodel.InventoryList.Where(x => x.ID == iostock.Inventory.ID).Single();

            //범위1 F .. T ... L
            viewmodel.Date = fmt.Date.AddMilliseconds(10);
            var lastst = formats.Where(x => x.Date < viewmodel.Date).OrderBy(x => x.Date).Last();
            int qty = 1;
            viewmodel.Quantity = qty;
            Assert.AreEqual(inventoryQty + qty, viewmodel.InventoryQuantity); //재고수량 증가 확인
            viewmodel.StockType = IOStockType.OUTGOING;
            Assert.AreEqual(inventoryQty - qty, viewmodel.InventoryQuantity); //재고수량 증가 확인

            //범위2 TF .... L
            viewmodel.StockType = IOStockType.INCOMING;
            viewmodel.Date = formats.First().Date.AddMilliseconds(-10000);
            Assert.AreEqual(inventoryQty + qty, viewmodel.InventoryQuantity); //재고수량 증가 확인

            viewmodel.StockType = IOStockType.OUTGOING;
            viewmodel.Date = formats.First().Date.AddMilliseconds(-10000);
            Assert.AreEqual(inventoryQty - qty, viewmodel.InventoryQuantity); //재고수량 증가 확인

            //범위3 F .... LT
            viewmodel.StockType = IOStockType.INCOMING;
            viewmodel.Date = formats.Last().Date.AddMilliseconds(1000);
            lastst = formats.Where(x => x.Date < viewmodel.Date).OrderBy(x => x.Date).Last();
            Assert.AreEqual(inventoryQty + qty, viewmodel.InventoryQuantity); //재고수량 증가 확인

            viewmodel.StockType = IOStockType.OUTGOING;
            Assert.AreEqual(inventoryQty - qty, viewmodel.InventoryQuantity); //재고수량 증가 확인
        }
        public IObservableIOStockProperties Record()
        {
            if (Product == null && string.IsNullOrEmpty(ProductText))
                throw new Exception("제품의 이름을 입력해주세요.");
            if (Inventory == null && string.IsNullOrEmpty(SpecificationText))
                throw new Exception("규격의 이름을 입력해주세요.");

            IObservableIOStockProperties result = null;

            switch (_mode)
            {
                case Mode.ADD:
                    CreateIOStockNewProperies();
                    ApplyModifiedInventoryProperties();
                    Format.ID = Guid.NewGuid().ToString();
                    DataDirector.GetInstance().DB.Insert(Format);
                    result = new ObservableIOStock(Format);
                    CollectionViewModelObserverSubject.GetInstance().NotifyNewItemAdded(result);
                    break;

                case Mode.MODIFY:
                    ApplyModifiedIOStockProperties();
                    ApplyModifiedInventoryProperties();
                    DataDirector.GetInstance().DB.Update(Format);
                    _originSource.Format = Format;
                    result = _originSource;
                    break;
            }
            //RefreshDataGridItems();
            return result;
        }
 public void Quantity7()
 {
     new Dummy().Create();
     IOStockFormat fmt = null;
     IEnumerable<IOStockFormat> formats;
     var inventory = DataDirector.GetInstance().CopyInventories().Random();
     formats = DataDirector.GetInstance().DB.Query<IOStockFormat>("select * from IOStockFormat where {0} = '{1}' order by Date;",
      "InventoryID", inventory.ID);
     fmt = formats.First();
     var iostock = new ObservableIOStock(fmt);
     int inventoryQty = iostock.Inventory.Quantity;
     IOStockDataAmenderViewModel viewmodel = new IOStockDataAmenderViewModel();
     viewmodel.StockType = IOStockType.OUTGOING;
     viewmodel.Product = iostock.Inventory.Product;
     viewmodel.Inventory = viewmodel.InventoryList.Where(x => x.ID == iostock.Inventory.ID).Single();
     viewmodel.Date = fmt.Date.AddDays(-10000);
     viewmodel.Quantity = 1;
     viewmodel.Record();
     CheckQuantity(inventory);
 }
 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();
 }
        public void DontSave()
        {
            new Dummy().Create();
            IOStockFormat fmt = null;
            fmt = DataDirector.GetInstance().DB.Select<IOStockFormat>().Random();
            var id = fmt.ID;
            var viewmodel = new IOStockDataAmenderViewModel(new ObservableIOStock(fmt));

            var specMemo = viewmodel.SpecificationMemo = "SOME SPECIFICATION MEMO";
            var maker = viewmodel.Maker = viewmodel.MakerList.Where(x => x != viewmodel.Maker).Random();
            var measure = viewmodel.Measure = viewmodel.MeasureList.Where(x => x != viewmodel.Measure).Random();
            var warehouse = viewmodel.Warehouse = viewmodel.WarehouseList.Where(x => x != viewmodel.Warehouse).Random();
            var employee = viewmodel.Employee = viewmodel.EmployeeList.Where(x => x != viewmodel.Employee).Random();
            var memo = viewmodel.Memo = "MEMO";
            var price = viewmodel.UnitPrice = 7777;

            fmt = DataDirector.GetInstance().DB.Select<IOStockFormat>(id);

            var obIOStock = new ObservableIOStock(fmt);
            Assert.AreNotEqual(specMemo, obIOStock.Inventory.Memo);
            Assert.AreNotEqual(maker, obIOStock.Inventory.Maker);
            Assert.AreNotEqual(measure, obIOStock.Inventory.Measure);
            Assert.AreNotEqual(warehouse, obIOStock.Warehouse);
            Assert.AreNotEqual(employee, obIOStock.Employee);
            Assert.AreNotEqual(memo, obIOStock.Memo);
        }
        public void Modify()
        {
            new Dummy().Create();
            IOStockFormat fmt = null;
            fmt = DataDirector.GetInstance().DB.Select<IOStockFormat>().Random(); DataDirector.GetInstance().DB.Select<IOStockFormat>().Random();
            IOStockType type = fmt.StockType;
            IOStockStatusViewModel iostockStatusViewModel = new IOStockStatusViewModel();
            IOStockDataAmenderViewModel viewmodel = new IOStockDataAmenderViewModel(new ObservableIOStock(fmt));

            Assert.AreEqual(type, viewmodel.StockType);
            string id = fmt.ID;
            var clientText = viewmodel.ClientText = "SOME CLIENT";
            viewmodel.Client = null;
            var warehouseText = viewmodel.WarehouseText = "SOME WAREHOUSE";
            viewmodel.Warehouse = null;
            var employeeText = viewmodel.EmployeeText = "SOME EMPLOYEE";
            viewmodel.Employee = null;
            var projectText = viewmodel.ProjectText = "SOME PROJECT";
            viewmodel.Project = null;
            var memo = viewmodel.Memo = "SOME MEMO";
            var specificationMemo = viewmodel.SpecificationMemo = "SOME SPEC_MEMO";
            var makerText = viewmodel.MakerText = "SOME MAKER";
            viewmodel.Maker = null;
            var measureText = viewmodel.MeasureText = "SOME MEASURE";
            viewmodel.Measure = null;
            var qty = viewmodel.Quantity = 1111;
            var price = viewmodel.UnitPrice = 30302;

            viewmodel.Record();

            fmt = DataDirector.GetInstance().DB.Select<IOStockFormat>(fmt.ID);
            ObservableIOStock stock = new ObservableIOStock(fmt);

            if (stock.StockType == IOStockType.INCOMING)
            {
                Assert.AreEqual(clientText, stock.Supplier.Name);
                Assert.AreEqual(warehouseText, stock.Warehouse.Name);
            }
            else if (stock.StockType == IOStockType.OUTGOING)
            {
                Assert.AreEqual(clientText, stock.Customer.Name);
                Assert.AreEqual(projectText, stock.Project.Name);
            }
            Assert.AreEqual(employeeText, stock.Employee.Name);
            Assert.AreEqual(memo, stock.Memo);
            Assert.AreEqual(makerText, stock.Inventory.Maker.Name);
            Assert.AreEqual(measureText, stock.Inventory.Measure.Name);
            Assert.AreEqual(type, stock.StockType);

            var ofd = DataDirector.GetInstance();
            Assert.IsNotNull(ofd.SearchField<Maker>(stock.Inventory.Maker.ID));
            Assert.IsNotNull(ofd.SearchField<Measure>(stock.Inventory.Measure.ID));
        }
        public void CheckInitializedProperties()
        {
            new Dummy().Create();
            IOStockFormat fmt = null;
            fmt = DataDirector.GetInstance().DB.Select<IOStockFormat>().Where(x => x.StockType == IOStockType.INCOMING).Random();
            ObservableIOStock obIOStock = new ObservableIOStock(fmt);
            IOStockDataAmenderViewModel viewmodel = new IOStockDataAmenderViewModel(obIOStock);

            Assert.AreEqual(obIOStock.Date, viewmodel.Date);
            Assert.AreEqual(obIOStock.StockType, viewmodel.StockType);
            Assert.AreEqual(obIOStock.Employee, viewmodel.Employee);
            Assert.AreEqual(obIOStock.Inventory.ID, viewmodel.Inventory.ID);
            Assert.AreEqual(obIOStock.Inventory.Product, viewmodel.Product);
            Assert.AreEqual(obIOStock.Inventory.Measure, viewmodel.Measure);
            Assert.AreEqual(obIOStock.Inventory.Maker, viewmodel.Maker);
            Assert.AreEqual(obIOStock.Warehouse, viewmodel.Warehouse);
            Assert.AreEqual(obIOStock.Supplier, viewmodel.Client);
            Assert.AreEqual(obIOStock.Quantity, viewmodel.Quantity);
            Assert.AreEqual(obIOStock.RemainingQuantity, viewmodel.RemainingQuantity);
            Assert.AreEqual(obIOStock.UnitPrice, viewmodel.UnitPrice);
        }
        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);
        }