public void CreateReceivedPurchaseOrderFromExistingData() { ReceivedBatch received = helper.GetBatchWithSpecificDate(new DateTime(2019, 7, 4)); int expectedPONumber = received.PONumber; DateTime expectedActivityDate = received.ActivityDate; BatchOperator expectedBatchOperator = received.ReceivingOperator; int expectedCount = 3; string expectedDateDisplay = "July 4, 2019"; ObservableCollection <ReceivedBatch> receivedBatches = new ObservableCollection <ReceivedBatch>() { received, received, received }; ReceivedPurchaseOrder receivedPO = new ReceivedPurchaseOrder( expectedPONumber, expectedActivityDate, expectedBatchOperator, receivedBatches ); Assert.AreEqual(expectedPONumber, receivedPO.PONumber); Assert.AreEqual(expectedActivityDate, receivedPO.ActivityDate); Assert.AreEqual(expectedDateDisplay, receivedPO.DisplayDate); Assert.AreSame(expectedBatchOperator, receivedPO.ReceivingOperator); Assert.AreEqual(expectedCount, receivedPO.ReceivedBatches.Count); }
ObservableCollection <ReceivedPurchaseOrder> AggregateRecordsByPONumber(ObservableCollection <ReceivedBatch> results) { Dictionary <int, ReceivedPurchaseOrder> aggregatedBatches = new Dictionary <int, ReceivedPurchaseOrder>(); foreach (ReceivedBatch batch in results) { if (aggregatedBatches.ContainsKey(batch.PONumber)) { aggregatedBatches[batch.PONumber].AddBatch(batch); } else { ReceivedPurchaseOrder receivedPO = new ReceivedPurchaseOrder( batch.PONumber, batch.ActivityDate, batch.ReceivingOperator ); receivedPO.AddBatch(batch); aggregatedBatches.Add(batch.PONumber, receivedPO); } } ObservableCollection <ReceivedPurchaseOrder> receivedPurchaseOrders = new ObservableCollection <ReceivedPurchaseOrder>(); foreach (KeyValuePair <int, ReceivedPurchaseOrder> received in aggregatedBatches) { receivedPurchaseOrders.Add(received.Value); } return(receivedPurchaseOrders); }
public void CreatedReceivedPurchaseOrderWithAnEmptySetOfReceivedBatches() { int expectedCount = 0; ReceivedBatch received = helper.GetUniqueBatch1(); ReceivedPurchaseOrder receivedPO = new ReceivedPurchaseOrder( received.PONumber, received.ActivityDate, received.ReceivingOperator ); Assert.AreEqual(expectedCount, receivedPO.ReceivedBatches.Count); }
public void ExecutedCommandWillPopulateReceivedBatchCollectionForTheSelectedPurchaseOrderRecord() { int expectedLedgerCount = 1; int expectedPreviewCount = 2; ReceivedPurchaseOrder receivedPO = CreatePurchaseOrderWithSingleEntry(); viewModel.RetreivedRecordsLedger.Add(receivedPO); viewModel.RetreivedRecordsLedgerSelectedIndex = 0; command.Execute(null); Assert.AreEqual(expectedLedgerCount, viewModel.RetreivedRecordsLedger.Count); Assert.AreEqual(expectedPreviewCount, viewModel.SelectedPurchaseOrderReceivedBatches.Count); }
public void CreatedReceivedPurchaseOrderAndAddReceivedBatchesToIt() { int expectedCount = 1; ReceivedBatch received = helper.GetUniqueBatch1(); ReceivedPurchaseOrder receivedPO = new ReceivedPurchaseOrder( received.PONumber, received.ActivityDate, received.ReceivingOperator ); receivedPO.AddBatch(received); Assert.AreEqual(expectedCount, receivedPO.ReceivedBatches.Count); }
ReceivedPurchaseOrder CreatePurchaseOrderWithSingleEntry() { ReceivedBatch firstBatch = helper.GetUniqueBatch1(); ReceivedBatch secondBatch = helper.GetUniqueBatch2(); ReceivedPurchaseOrder receivedPO = new ReceivedPurchaseOrder( firstBatch.PONumber, firstBatch.ActivityDate, firstBatch.ReceivingOperator ); receivedPO.AddBatch(firstBatch); receivedPO.AddBatch(secondBatch); return(receivedPO); }
public void CommandThatCanNoLongerExecuteWillClearTheReceivedBatchesCollection() { int expectedLedgerCountBefore = 1; int expectedPreviewCountBefore = 2; int expectedLedgerCountAfter = 0; int expectedPreviewCountAfter = 0; ReceivedPurchaseOrder receivedPO = CreatePurchaseOrderWithSingleEntry(); viewModel.RetreivedRecordsLedger.Add(receivedPO); viewModel.RetreivedRecordsLedgerSelectedIndex = 0; command.Execute(null); Assert.AreEqual(expectedLedgerCountBefore, viewModel.RetreivedRecordsLedger.Count); Assert.AreEqual(expectedPreviewCountBefore, viewModel.SelectedPurchaseOrderReceivedBatches.Count); viewModel.RetreivedRecordsLedger.Clear(); viewModel.RetreivedRecordsLedgerSelectedIndex = -1; command.CanExecute(null); Assert.AreEqual(expectedLedgerCountAfter, viewModel.RetreivedRecordsLedger.Count); Assert.AreEqual(expectedPreviewCountAfter, viewModel.SelectedPurchaseOrderReceivedBatches.Count); }