Example #1
0
		public void Deserialization()
		{
            XmlFirstUpperReader fu = new XmlFirstUpperReader("../../Common/UpperLowerTests/Customer.xml");
            XmlReaderSettings settings = new XmlReaderSettings();
            settings.ValidationType = ValidationType.Schema;
            settings.Schemas.Add(XmlSchema.Read(XmlReader.Create("../../Common/UpperLowerTests/Customer.xsd"), null));
			XmlReader vr = XmlReader.Create(fu, settings);			
			XmlSerializer ser = new XmlSerializer(typeof(Customer));
			Customer c = (Customer) ser.Deserialize(vr);

			Assert.AreEqual("0736", c.Id);
			Assert.AreEqual("Daniel Cazzulino", c.Name);
			Assert.AreEqual(25, c.Order.Id);
		}
Example #2
0
		public void Serialization()
		{
			XmlFirstUpperReader fu = new XmlFirstUpperReader(Globals.GetResource( 
				this.GetType().Namespace + ".Customer.xml"));
			XmlSerializer ser = new XmlSerializer(typeof(Customer));
			Customer c = (Customer) ser.Deserialize(fu);

			StringWriter sw = new StringWriter();
			XmlFirstLowerWriter fl = new XmlFirstLowerWriter(sw);

			ser.Serialize(fl, c);

			Assert.AreEqual("<?xml version=\"1.0\" encoding=\"utf-16\"?><customer xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" id=\"0736\" xmlns=\"mvp-xml-customer\"><name>Daniel Cazzulino</name><order id=\"25\" /></customer>", 
				sw.ToString());
		}
Example #3
0
		public void Deserialization()
		{
            XmlFirstUpperReader fu = new XmlFirstUpperReader(Globals.GetResource( 
				this.GetType().Namespace + ".Customer.xml"));

			XmlValidatingReader vr = new XmlValidatingReader(fu);
			vr.Schemas.Add(XmlSchema.Read(Globals.GetResource(
				this.GetType().Namespace + ".Customer.xsd"), null));

			XmlSerializer ser = new XmlSerializer(typeof(Customer));
			Customer c = (Customer) ser.Deserialize(vr);

			Assert.AreEqual("0736", c.Id);
			Assert.AreEqual("Daniel Cazzulino", c.Name);
			Assert.AreEqual(25, c.Order.Id);
		}
Example #4
0
		public void XmlFirstUpperReader()
		{
			string xml = "<customer id='1' pp:id='aba' xmlns='urn-kzu' xmlns:pp='urn-pepenamespace'><pp:order /><order id='1'>Chocolates</order></customer>";

			XmlFirstUpperReader fr = new XmlFirstUpperReader(new StringReader(xml));
            
			fr.MoveToContent();
			Assert.AreEqual("Customer", fr.LocalName);
			fr.MoveToFirstAttribute();
			Assert.AreEqual("Id", fr.LocalName);
			fr.MoveToNextAttribute();
			Assert.AreEqual("pp:Id", fr.Name);

			// Namespace ordering is not guaranteed.
			fr.MoveToNextAttribute();
			Assert.IsTrue( fr.Name == "xmlns" || fr.Name == "xmlns:pp" );
			fr.MoveToNextAttribute();
			Assert.IsTrue( fr.Name == "xmlns" || fr.Name == "xmlns:pp" );

			fr.MoveToElement();
			fr.Read();
			Assert.AreEqual("pp:Order", fr.Name);
		}