public void DictionaryNamespaceSerializationTest() { const string result = @"<CellPhone_DictionaryNamespace xmlns:x1=""http://namespace.org/x1"" xmlns:p1=""namespace/for/prices/only"" xmlns=""http://namespace.org/nsmain""> <x1:TheName>HTC</x1:TheName> <OS>Windows Phone 8</OS> <p1:Prices> <p1:KeyValuePairOfStringDouble> <p1:Key>red</p1:Key> <p1:Value>120</p1:Value> </p1:KeyValuePairOfStringDouble> <p1:KeyValuePairOfStringDouble> <p1:Key>blue</p1:Key> <p1:Value>110</p1:Value> </p1:KeyValuePairOfStringDouble> <p1:KeyValuePairOfStringDouble> <p1:Key>black</p1:Key> <p1:Value>140</p1:Value> </p1:KeyValuePairOfStringDouble> </p1:Prices> </CellPhone_DictionaryNamespace>"; var serializer = new YAXSerializer(typeof(CellPhone_DictionaryNamespace), YAXExceptionHandlingPolicies.DoNotThrow, YAXExceptionTypes.Warning, YAXSerializationOptions.SerializeNullObjects); var got = serializer.Serialize(CellPhone_DictionaryNamespace.GetSampleInstance()); Assert.That(got, Is.EqualTo(result)); }
public void DictionaryNamespaceForAllItemsDeserializationTest() { var serializer = new YAXSerializer(typeof(CellPhone_DictionaryNamespace), YAXExceptionHandlingPolicies.DoNotThrow, YAXExceptionTypes.Warning, YAXSerializationOptions.SerializeNullObjects); string got = serializer.Serialize(CellPhone_DictionaryNamespace.GetSampleInstance()); var deserialized = serializer.Deserialize(got) as CellPhone_DictionaryNamespace; Assert.That(deserialized, Is.Not.Null); Assert.That(serializer.ParsingErrors, Has.Count.EqualTo(0)); }