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);
        }
Beispiel #2
0
        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 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);
        }