Ejemplo n.º 1
0
        public void DictionaryNamespaceForAllItemsSerializationTest()
        {
            const string result =
                @"<CellPhone_DictionaryNamespaceForAllItems xmlns:p1=""http://namespace.org/brand"" xmlns:p2=""http://namespace.org/prices"" xmlns:p3=""http://namespace.org/pricepair"" xmlns:p4=""http://namespace.org/color"" xmlns:p5=""http://namespace.org/pricevalue"">
  <p1:Brand>Samsung Galaxy Nexus</p1:Brand>
  <OS>Android</OS>
  <p2:ThePrices>
    <p3:PricePair>
      <p4:TheColor>red</p4:TheColor>
      <p5:ThePrice>120</p5:ThePrice>
    </p3:PricePair>
    <p3:PricePair>
      <p4:TheColor>blue</p4:TheColor>
      <p5:ThePrice>110</p5:ThePrice>
    </p3:PricePair>
    <p3:PricePair>
      <p4:TheColor>black</p4:TheColor>
      <p5:ThePrice>140</p5:ThePrice>
    </p3:PricePair>
  </p2:ThePrices>
</CellPhone_DictionaryNamespaceForAllItems>";
            var serializer = new YAXSerializer(typeof(CellPhone_DictionaryNamespaceForAllItems),
                                               YAXExceptionHandlingPolicies.DoNotThrow, YAXExceptionTypes.Warning,
                                               YAXSerializationOptions.SerializeNullObjects);
            var got = serializer.Serialize(CellPhone_DictionaryNamespaceForAllItems.GetSampleInstance());

            Assert.That(got, Is.EqualTo(result));
        }
Ejemplo n.º 2
0
        public void DictionaryNamespaceDeserializationTest()
        {
            var    serializer   = new YAXSerializer(typeof(CellPhone_DictionaryNamespaceForAllItems), YAXExceptionHandlingPolicies.DoNotThrow, YAXExceptionTypes.Warning, YAXSerializationOptions.SerializeNullObjects);
            string got          = serializer.Serialize(CellPhone_DictionaryNamespaceForAllItems.GetSampleInstance());
            var    deserialized = serializer.Deserialize(got) as CellPhone_DictionaryNamespaceForAllItems;

            Assert.That(deserialized, Is.Not.Null);
            Assert.That(serializer.ParsingErrors, Has.Count.EqualTo(0));
        }