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 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 CheckStackTypePropertyAction()
 {
     new Dummy().Create();
     IOStockDataAmenderViewModel viewmodel = new IOStockDataAmenderViewModel();
     //입고시 제품과 규격을 설정한다.
     viewmodel.StockType = IOStockType.INCOMING;
     viewmodel.ProductText = "some product";
     viewmodel.SpecificationText = "some specification name";
     //출고로 바꿀 경우
     viewmodel.StockType = IOStockType.OUTGOING;
     //설정된 프로퍼티를 null로 초기화한다.
     Assert.IsNull(viewmodel.ProductText);
     Assert.IsNull(viewmodel.SpecificationText);
     Assert.IsNull(viewmodel.Product);
     Assert.IsNull(viewmodel.Inventory);
     //출고에서 제품과 규격을 선택한 후
     var product = viewmodel.Product = DataDirector.GetInstance().CopyFields<Product>().Random();
     var inven = viewmodel.Inventory = viewmodel.InventoryList.Random();
     //입고로 전환해도 제품과 규격 프로퍼티는 그대로 있고
     viewmodel.StockType = IOStockType.INCOMING;
     //다시 출고로 바뀌어도 마찬가지이다.
     viewmodel.StockType = IOStockType.OUTGOING;
     //결과
     Assert.IsNotNull(viewmodel.Product);
     Assert.IsNotNull(viewmodel.ProductText);
     Assert.IsNotNull(viewmodel.Inventory);
 }
        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 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 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 BoundBooleanPropertiesLockOnOff()
 {
     IOStockDataAmenderViewModel viewmodel = new IOStockDataAmenderViewModel();
     viewmodel.StockType = IOStockType.OUTGOING;
     //제품이름 변경 금지
     Assert.IsTrue(viewmodel.IsReadOnlyProductTextBox);
     //보관장소 금지
     Assert.IsFalse(viewmodel.IsEnabledWarehouseComboBox);
     //프로젝트는 열려야함
     Assert.IsTrue(viewmodel.IsEnabledProjectComboBox);
     viewmodel.StockType = IOStockType.INCOMING;
     Assert.IsFalse(viewmodel.IsReadOnlyProductTextBox);
     Assert.IsTrue(viewmodel.IsEnabledWarehouseComboBox);
     Assert.IsFalse(viewmodel.IsEnabledProjectComboBox);
 }
 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 Quantity()
        {
            new Dummy().Create();
            IOStockDataAmenderViewModel viewmodel = new IOStockDataAmenderViewModel();

            viewmodel.StockType = IOStockType.OUTGOING;
            var product = viewmodel.Product = DataDirector.GetInstance().CopyFields<Product>().Random();
            var specificationName = viewmodel.Inventory = viewmodel.InventoryList.Random();
            var inventoryQty = viewmodel.Inventory.Quantity;
            if (inventoryQty <= 1)
                return;
            viewmodel.Quantity = inventoryQty - 1; //현재 재고는 1개

            Assert.AreEqual(1, viewmodel.InventoryQuantity); //현재 재고도 1개
        }
        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 WhenSelectSpecificationThenInventoryPropertiesInitialize()
        {
            new Dummy().Create();
            IOStockDataAmenderViewModel viewmodel = new IOStockDataAmenderViewModel();

            var product = viewmodel.Product = DataDirector.GetInstance().CopyFields<Product>().Random();
            var inventory = viewmodel.Inventory = viewmodel.InventoryList.Random();

            Assert.AreEqual(viewmodel.Inventory.Memo, viewmodel.SpecificationMemo);
            Assert.AreEqual(viewmodel.Inventory.Maker, viewmodel.Maker);
            Assert.AreEqual(viewmodel.Inventory.Measure, viewmodel.Measure);
        }
 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 WhenCreateNewProductThenPropertiesOfInventoryBecomeNull()
 {
     new Dummy().Create();
     IOStockDataAmenderViewModel viewmodel = new IOStockDataAmenderViewModel();
     //기존의 제품과 규격을 선택
     viewmodel.StockType = IOStockType.INCOMING;
     var product = viewmodel.Product = DataDirector.GetInstance().CopyFields<Product>().Random();
     var inventory = viewmodel.Inventory = viewmodel.InventoryList.Random();
     inventory.Memo = "some specification memo";
     viewmodel.MeasureText = "some measure";
     viewmodel.MakerText = "some maker";
     //규격의 관련 속성이 로드됨을 확인
     Assert.IsNotNull(viewmodel.ProductText);
     Assert.IsNotNull(viewmodel.SpecificationMemo);
     Assert.IsNotNull(viewmodel.Maker);
     Assert.IsNotNull(viewmodel.Measure);
     //새로운 제품을 쓰고자 하면
     viewmodel.ProductText = "some product text";
     //관련 규격 데이터들을 널로 초기화 되었는지 확인
     Assert.IsNull(viewmodel.Project);
     Assert.IsNull(viewmodel.Inventory);
     Assert.IsNull(viewmodel.SpecificationMemo);
     Assert.IsNull(viewmodel.Maker);
     Assert.IsNull(viewmodel.Measure);
     Assert.IsNull(viewmodel.MakerText);
     Assert.IsNull(viewmodel.MeasureText);
 }
        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 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 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 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 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);
 }