コード例 #1
0
        public void TestAddRemoveShipments()
        {
            Batch    batch         = Batch.Create();
            Shipment shipment      = Shipment.Create(shipmentParameters);
            Shipment otherShipment = Shipment.Create(shipmentParameters);

            while (batch.state != "created")
            {
                batch = Batch.Retrieve(batch.id);
            }
            batch.AddShipments(new List <Shipment>()
            {
                shipment, otherShipment
            });

            while (batch.shipments == null)
            {
                batch = Batch.Retrieve(batch.id);
            }
            List <string> shipmentIds = batch.shipments.Select(ship => ship.id).ToList();

            Assert.AreEqual(batch.num_shipments, 2);
            CollectionAssert.Contains(shipmentIds, shipment.id);
            CollectionAssert.Contains(shipmentIds, otherShipment.id);

            batch.RemoveShipments(new List <Shipment>()
            {
                shipment, otherShipment
            });
            Assert.AreEqual(batch.num_shipments, 0);
        }