Beispiel #1
0
        public void Can_Serialize_An_Address_And_Store_In_ExtendedDataCollection()
        {
            //// Arrange
            var extendedData = new ExtendedDataCollection();

            //// Act
            extendedData.AddAddress(_address, AddressType.Billing);
            Console.Write(extendedData.SerializeToXml());

            //// Assert
            Assert.DoesNotThrow(() => XDocument.Parse(extendedData.GetValue(Constants.ExtendedDataKeys.BillingAddress)));
        }
Beispiel #2
0
        public void Can_Serialize_ExtendedData_To_Xml()
        {
            //// Arrange
            _extendedData.SetValue("key1", "value1");
            _extendedData.SetValue("key2", "value2");
            _extendedData.SetValue("key3", "value3");
            _extendedData.SetValue("key4", "value4");
            _extendedData.SetValue("key5", "value5");

            //// Act
            var xml = _extendedData.SerializeToXml();

            //// Assert
            Console.Write(xml);
            Assert.DoesNotThrow(() => XDocument.Parse(xml));
        }
Beispiel #3
0
        public void Can_Deserialize_A_LineItemCollection_Stored_In_A_Serialized_ExtendedDataCollection()
        {
            //// Arrange
            var extendedDataContainer = new ExtendedDataCollection();
            var extendedDataWrapper   = new ExtendedDataCollection();

            extendedDataWrapper.AddLineItemCollection(_shipment.Items);
            extendedDataContainer.AddExtendedDataCollection(extendedDataWrapper);
            Console.Write(extendedDataContainer.SerializeToXml());

            //// Act
            var retrievedExtendedDataWrapper = extendedDataContainer.GetExtendedDataCollection();

            Assert.NotNull(retrievedExtendedDataWrapper);
            var lineItemCollection = retrievedExtendedDataWrapper.GetLineItemCollection <ItemCacheLineItem>();

            //// Assert
            Assert.NotNull(lineItemCollection);
            Assert.IsTrue(lineItemCollection.Any());
        }
        public void Can_Serialize_An_Address_And_Store_In_ExtendedDataCollection()
        {
            //// Arrange
            var extendedData = new ExtendedDataCollection();

            //// Act
            extendedData.AddAddress(_address, AddressType.Billing);
            Console.Write(extendedData.SerializeToXml());

            //// Assert
            Assert.DoesNotThrow(() => XDocument.Parse(extendedData.GetValue(Constants.ExtendedDataKeys.BillingAddress)));
        }
        public void Can_Deserialize_A_LineItemCollection_Stored_In_A_Serialized_ExtendedDataCollection()
        {
            //// Arrange
            var extendedDataContainer = new ExtendedDataCollection();
            var extendedDataWrapper = new ExtendedDataCollection();
            extendedDataWrapper.AddLineItemCollection(_shipment.Items);
            extendedDataContainer.AddExtendedDataCollection(extendedDataWrapper);
            Console.Write(extendedDataContainer.SerializeToXml());

            //// Act
            var retrievedExtendedDataWrapper = extendedDataContainer.GetExtendedDataCollection();
            Assert.NotNull(retrievedExtendedDataWrapper);
            var lineItemCollection = retrievedExtendedDataWrapper.GetLineItemCollection<ItemCacheLineItem>();

            //// Assert
            Assert.NotNull(lineItemCollection);
            Assert.IsTrue(lineItemCollection.Any());
        }
 /// <summary>
 /// The add extended data collection.
 /// </summary>
 /// <param name="extendedData">
 /// The extended data.
 /// </param>
 /// <param name="extendedDataToSerialize">
 /// The extended data to serialize.
 /// </param>
 public static void AddExtendedDataCollection(this ExtendedDataCollection extendedData, ExtendedDataCollection extendedDataToSerialize)
 {
     extendedData.SetValue(Constants.ExtendedDataKeys.ExtendedData, extendedDataToSerialize.SerializeToXml());
 }