Ejemplo n.º 1
0
        public void TestBatches()
        {
            var addresses = _client.GetAddresses();
            var parcels   = _client.GetParcels();

            var batch = _client.CreateBatch(new Batch
            {
                Shipments = new List <BatchShipment>
                {
                    new BatchShipment
                    {
                        Parcel      = parcels[0],
                        FromAddress = addresses[0],
                        ToAddress   = addresses[1],
                        Carrier     = "USPS",
                        Service     = "Priority",
                    },
                    new BatchShipment
                    {
                        Parcel      = parcels[1],
                        FromAddress = addresses[1],
                        ToAddress   = addresses[2],
                    },
                }
            });

            Assert.IsNotNull(batch.Id);

            // it takes a few minutes for the shipments to be added :(
            // so we can't verify batch.Status.CreatedCount == 2 here

            var sameAsBatch = _client.GetBatch(batch.Id);

            Assert.AreEqual(batch.Id, sameAsBatch.Id);

            var allBatches  = _client.GetBatches();
            var shouldExist = allBatches.SingleOrDefault(x => string.Equals(x.Id, batch.Id));

            Assert.IsNotNull(shouldExist);
        }