Exemple #1
0
 public ReceivedPurchaseOrderEditorViewModel(
     EditablePurchaseOrder purchaseOrder,
     IColorList colorList,
     IBatchNumberValidator batchNumberValidator,
     IBatchOperatorSource operatorSource,
     IActiveInventorySource inventorySource,
     IReceivedBatchSource receivedBatchSource,
     IImplementedBatchSource implementedBatchSource
     )
 {
     this.purchaseOrder          = purchaseOrder;
     this.operatorSource         = operatorSource;
     this.inventorySource        = inventorySource;
     this.receivedBatchSource    = receivedBatchSource;
     this.implementedBatchSource = implementedBatchSource;
     receivedBatches             = new ObservableCollection <ReceivedBatch>();
     ReceivedBatch = new ReceivedBatch();
     ImportPurchaseOrderInformation();
     UpdateReceivedBatchCommand    = new UpdatePurchaseOrderReceivingRecordCommand(this);
     UpdatePurchaseOrderCommand    = new UpdatePurchaseOrderHeaderCommand(this);
     DeleteReceivingRecordCommand  = new DeletePurchaseOrderReceivingRecordCommand(this);
     ReceivedBatchSelectionChanged = new ReceivedBatchForEditingSelectionChangedCommand(this);
     UpdateText                   = "Save Item";
     this.colorList               = colorList;
     this.batchNumberValidator    = batchNumberValidator;
     SelectedColorIndex           = 0;
     ReceivedBatchesSelectedIndex = -1;
 }
        public void CommandWillExecuteIfSelectedBatchForDeletionHasBeenImplementedButHasAvailableQuantityInInventory()
        {
            string batchNumber = viewModel.ReceivedBatches[0].BatchNumber;

            implementedBatchSource.AddBatchToImplementationLedger(batchNumber, DateTime.Now, operatorSource.FindBatchOperator(1));
            receivedBatchSource.SaveReceivedBatch(new ReceivedBatch("White", whiteBatch, activityDate, 5, 22222, operatorSource.FindBatchOperator(1)));

            viewModel = new ReceivedPurchaseOrderEditorViewModel(
                receivedBatchSource.GetPurchaseOrderForEditing(22222),
                new DuracolorIntermixColorList(),
                new DuracolorIntermixBatchNumberValidator(),
                operatorSource,
                inventorySource,
                receivedBatchSource,
                implementedBatchSource
                );

            command = new DeletePurchaseOrderReceivingRecordCommand(viewModel);
            viewModel.ReceivedBatchesSelectedIndex = 0;

            Assert.True(command.CanExecute(null));
        }
        public override void SetUp()
        {
            sqliteHelper = new SQLiteDatabaseHelper();
            sqliteHelper.CreateTestDatabase();
            SQLiteStoreContext context = new SQLiteStoreContext(sqliteHelper.DatabaseFile);

            inventorySource        = new SQLiteActiveInventorySource(context);
            receivedBatchSource    = new SQLiteReceivedBatchSource(context, inventorySource);
            implementedBatchSource = new SQLiteImplementedBatchSource(context, inventorySource);
            operatorSource         = new SQLiteBatchOperatorSource(context);
            base.SetUp();

            viewModel = new ReceivedPurchaseOrderEditorViewModel(
                receivedBatchSource.GetPurchaseOrderForEditing(originalPONumber),
                new DuracolorIntermixColorList(),
                new DuracolorIntermixBatchNumberValidator(),
                operatorSource,
                inventorySource,
                receivedBatchSource,
                implementedBatchSource
                );

            command = new DeletePurchaseOrderReceivingRecordCommand(viewModel);
        }