public void Add() { new Dummy().Create(); IOStockDataAmenderViewModel viewmodel = new IOStockDataAmenderViewModel(); InventoryStatusViewModel inventoryStatusViewModel = new InventoryStatusViewModel(); IOStockStatusViewModel iostockStatusViewModel = new IOStockStatusViewModel(); //날짜를 선택 iostockStatusViewModel.SelectedGroupItem = IOStockStatusViewModel.GROUPITEM_DATE; iostockStatusViewModel.DatePickerViewModel.TodayCommand.Execute(null); //올해 버튼을 클릭 Assert.IsFalse(viewmodel.IsReadOnlyProductTextBox); //제품 이름 변경 가능 Assert.IsTrue(viewmodel.ProductSearchCommand.CanExecute(null)); //제품 선택 가능 //정보 입력 viewmodel.StockType = IOStockType.INCOMING; viewmodel.ProductText = "some product"; Assert.IsTrue(viewmodel.Product == null); var spec = viewmodel.SpecificationText = "some specification"; var specMemo = viewmodel.SpecificationMemo = "some specification meno"; var maker = viewmodel.MakerText = "some maker"; var measure = viewmodel.MeasureText = "some measure"; var client = viewmodel.ClientText = "some client"; var warehouse = viewmodel.WarehouseText = "some warehouse"; var project = viewmodel.ProjectText = "some project"; var employee = viewmodel.EmployeeText = "some name"; var memo = viewmodel.Memo = "some memo"; var qty = viewmodel.Quantity = 666; var price = viewmodel.UnitPrice = 6666; var remain = viewmodel.RemainingQuantity; //저장 var iostock = viewmodel.Record(); Assert.IsTrue(iostock.StockType == IOStockType.INCOMING); Assert.IsTrue(iostock.Supplier != null); Assert.IsTrue(iostock.Customer == null); //입출고 데이터그리드에 추가되었는지 확인 Assert.IsTrue(iostockStatusViewModel.DataGridViewModel.Items.Any(x => x.ID == iostock.ID)); var inoutStock = iostockStatusViewModel.DataGridViewModel.Items.Where(x => x.ID == iostock.ID).Single(); //재고 데이터그리드에 추가되었는지 확인 Assert.IsTrue(inventoryStatusViewModel.GetDataGridItems().Any(x => x.ID == iostock.Inventory.ID)); var inventory = inventoryStatusViewModel.GetDataGridItems().Where(x => x.ID == iostock.Inventory.ID).Single(); var oid = DataDirector.GetInstance(); //검사 Assert.IsNotNull(oid.SearchInventory(iostock.Inventory.ID)); //inventory director에 추가되었는지 확인한다. Assert.AreEqual(spec, iostock.Inventory.Specification); Assert.AreEqual(specMemo, iostock.Inventory.Memo); Assert.AreEqual(maker, iostock.Inventory.Maker.Name); Assert.AreEqual(measure, iostock.Inventory.Measure.Name); Assert.AreEqual(client, iostock.Supplier.Name); Assert.AreEqual(warehouse, iostock.Warehouse.Name); Assert.AreEqual(employee, iostock.Employee.Name); Assert.AreEqual((int)qty, iostock.Quantity); Assert.AreEqual(memo, iostock.Memo); Assert.AreEqual(price, iostock.UnitPrice); Assert.AreEqual(qty, iostock.RemainingQuantity); Assert.AreEqual((int)qty, iostock.Inventory.Quantity); var ofd = DataDirector.GetInstance(); Assert.IsNotNull(ofd.SearchField<Maker>(iostock.Inventory.Maker.ID)); Assert.IsNotNull(ofd.SearchField<Measure>(iostock.Inventory.Measure.ID)); }
public void Add2() { new Dummy().Create(); IOStockDataAmenderViewModel viewmodel = new IOStockDataAmenderViewModel(); //설정 viewmodel.StockType = IOStockType.INCOMING; var product = viewmodel.Product = DataDirector.GetInstance().CopyFields<Product>().Random(); var inven = viewmodel.Inventory = viewmodel.InventoryList.Random(); var specMemo = viewmodel.SpecificationMemo = "some memo"; var maker = viewmodel.Maker = viewmodel.MakerList.Random(); var measure = viewmodel.Measure = viewmodel.MeasureList.Random(); var client = viewmodel.Client = viewmodel.ClientList.Random(); var warehouse = viewmodel.Warehouse = viewmodel.WarehouseList.Random(); var employee = viewmodel.Employee = viewmodel.EmployeeList.Random(); var memo = viewmodel.Memo = "some memo"; viewmodel.UnitPrice = 6666; var stock = viewmodel.Record(); //검사 Assert.AreEqual(product, stock.Inventory.Product); Assert.AreEqual(inven.ID, stock.Inventory.ID); Assert.AreEqual(specMemo, stock.Inventory.Memo); Assert.AreEqual(maker, stock.Inventory.Maker); Assert.AreEqual(measure, stock.Inventory.Measure); Assert.AreEqual(warehouse, stock.Warehouse); Assert.AreEqual(employee, stock.Employee); Assert.AreEqual(memo, stock.Memo); }
public void LogicPatten00() { new Dummy().Create(); IOStockDataAmenderViewModel viewmodel = new IOStockDataAmenderViewModel(); var product = viewmodel.Product = DataDirector.GetInstance().CopyFields<Product>().Random(); var specificationName = viewmodel.Inventory = viewmodel.InventoryList.Random(); var productText = viewmodel.ProductText = "new product text"; var specificationText = viewmodel.SpecificationText = "new specification text"; Assert.IsNull(viewmodel.InventoryList); var stock = viewmodel.Record(); Assert.AreEqual(productText, stock.Inventory.Product.Name); Assert.AreEqual(specificationText, stock.Inventory.Specification); }
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 Quantity4() { new Dummy().Create(); IOStockStatusViewModel iostockStatusViewModel = new IOStockStatusViewModel(); IOStockDataAmenderViewModel viewmodel = new IOStockDataAmenderViewModel(); //설정 viewmodel.StockType = new Random().NextDouble() > 0.5 ? IOStockType.INCOMING : IOStockType.OUTGOING; var product = viewmodel.Product = DataDirector.GetInstance().CopyFields<Product>().Random(); var inven = viewmodel.Inventory = viewmodel.InventoryList.Random(); var beforeInvenQty = inven.Quantity; var date = viewmodel.Date = DateTime.Now.AddDays(-600.0 * new Random().NextDouble()); //과거로 저장 int qty = new Random().Next(1, 10); viewmodel.Quantity = qty; //저장 IObservableIOStockProperties obIOStock = viewmodel.Record(); CheckQuantity(obIOStock.Inventory as ObservableInventory); }
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 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 Modify3() { new Dummy().Create(); IOStockFormat fmt = null; fmt = DataDirector.GetInstance().DB.Select<IOStockFormat>().Random(); var viewmodel = new IOStockDataAmenderViewModel(new ObservableIOStock(fmt)); var inven = DataDirector.GetInstance().SearchInventory(fmt.InventoryID); string makerId = inven.Maker.ID; string measureId = inven.Measure.ID; viewmodel.Maker = null; viewmodel.Measure = null; viewmodel.Client = null; viewmodel.Warehouse = null; viewmodel.Employee = null; string maker = viewmodel.MakerText = "some maker"; string measure = viewmodel.MeasureText = "some measure"; string client = viewmodel.ClientText = "some client"; string ware = viewmodel.WarehouseText = "some warehouse"; string employee = viewmodel.EmployeeText = "some employee"; var stock = viewmodel.Record(); switch (stock.StockType) { case IOStockType.INCOMING: Assert.AreEqual(ware, stock.Warehouse.Name); Assert.AreEqual(fmt.WarehouseID, stock.Warehouse.ID); break; case IOStockType.OUTGOING: break; } Assert.AreEqual(maker, stock.Inventory.Maker.Name); Assert.AreEqual(measure, stock.Inventory.Measure.Name); Assert.AreEqual(employee, stock.Employee.Name); Assert.AreEqual(fmt.EmployeeID, stock.Employee.ID); Assert.AreEqual(makerId, stock.Inventory.Maker.ID); Assert.AreEqual(measureId, stock.Inventory.Measure.ID); }
public void Modify2() { new Dummy().Create(); IOStockFormat fmt = null; fmt = DataDirector.GetInstance().DB.Select<IOStockFormat>().Random(); var viewmodel = new IOStockDataAmenderViewModel(new ObservableIOStock(fmt)); var specMemo = viewmodel.SpecificationMemo = "SOME SPECIFICATION MEMO"; var maker = viewmodel.Maker = viewmodel.MakerList.Random(); var measure = viewmodel.Measure = viewmodel.MeasureList.Random(); var client = viewmodel.Client = viewmodel.ClientList.Random(); var warehouse = viewmodel.Warehouse = viewmodel.WarehouseList.Random(); var employee = viewmodel.Employee = viewmodel.EmployeeList.Random(); var memo = viewmodel.Memo = "MEMO"; var price = viewmodel.UnitPrice = 7777; var stock = viewmodel.Record(); Assert.AreEqual(specMemo, stock.Inventory.Memo); Assert.AreEqual(maker, stock.Inventory.Maker); Assert.AreEqual(measure, stock.Inventory.Measure); Assert.AreEqual(warehouse, stock.Warehouse); Assert.AreEqual(employee, stock.Employee); Assert.AreEqual(memo, stock.Memo); Assert.AreEqual(price, stock.UnitPrice); }
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 Add3() { new Dummy().Create(); IOStockDataAmenderViewModel viewmodel = new IOStockDataAmenderViewModel(); //설정 var product = viewmodel.Product = DataDirector.GetInstance().CopyFields<Product>().Random(); viewmodel.Inventory = null; var specificationName = viewmodel.SpecificationText = "some specification"; var specMemo = viewmodel.SpecificationMemo = "some specification memo"; var maker = viewmodel.Maker = viewmodel.MakerList.Random(); var measure = viewmodel.Measure = viewmodel.MeasureList.Random(); var client = viewmodel.Client = viewmodel.ClientList.Random(); var warehouse = viewmodel.Warehouse = viewmodel.WarehouseList.Random(); var employee = viewmodel.Employee = viewmodel.EmployeeList.Random(); var memo = viewmodel.Memo = "some memo"; viewmodel.UnitPrice = 6666; var obIOStock = viewmodel.Record(); //검사 Assert.AreEqual(product, obIOStock.Inventory.Product); Assert.AreEqual(specificationName, obIOStock.Inventory.Specification); Assert.AreEqual(specMemo, obIOStock.Inventory.Memo); Assert.AreEqual(maker, obIOStock.Inventory.Maker); Assert.AreEqual(measure, obIOStock.Inventory.Measure); Assert.AreEqual(warehouse, obIOStock.Warehouse); Assert.AreEqual(employee, obIOStock.Employee); Assert.AreEqual(memo, obIOStock.Memo); }