public virtual void TestSerialize() { object value = GetValue(); string xml = xstream.ToXml(value); Assert.IsNotNull(xml); Assert.AreEqual("<" + xmlName + ">" + value.ToString() + "</" + xmlName + ">", xml); }
public void TestStreamSimpleArrayList() { ArrayList list = new ArrayList(5); list.Add(TestRandomizer.GetInt()); list.Add(TestRandomizer.GetString()); list.Add(TestRandomizer.GetDecimal()); list.Add("last"); XStream xs = new XStream(); string xml = xs.ToXml(list); Assert.IsNotNull(xml); Assert.IsTrue(xml.Length > 0); IList rlist = xs.FromXml(xml) as IList; Assert.IsNotNull(rlist); Assert.AreEqual(list.Count, rlist.Count); for (int i = 0; i < list.Count; i++) { Assert.AreEqual(list[i], rlist[i]); } }
internal string SerialiseAndDeserialise(object value, AssertEqualsDelegate equalsDelegate) { string actualSerialisedObject = xstream.ToXml(value); Console.WriteLine(actualSerialisedObject); equalsDelegate(value, xstream.FromXml(actualSerialisedObject)); return(actualSerialisedObject); }
public void act() { XStream xs = new XStream(); xs.Alias("person", typeof(TestPerson)); string xml = xs.ToXml(person); actual = xs.FromXml <TestPerson>(xml); }
public void act() { XStream xs = new XStream(); xs.Alias <TestPerson>("person"); string xml = xs.ToXml(person); actual = xs.FromXml(xml) as TestPerson; }
public void ShouldAllowAliasingOfAClass() { var xStream = new XStream(); xStream.Alias<Software>("software"); const string expectedXml = "<software><name>apache</name></software>"; Assert.That(xStream.ToXml(new Software("apache")), Is.EqualTo(expectedXml)); Assert.That(xStream.FromXml(expectedXml), Is.EqualTo(new Software("apache"))); }
public void should_serialize_without_the_full_class_name() { var map = new XStream().AutoAlias <TestArray35>(); var xml = map.ToXml(new TestArray35 { people = new[] { new TestPerson35 { ID = 12, Name = "Joe" } } }); Assert.AreEqual("<TestArray35><people><TestPerson35><ID>12</ID><Name>Joe</Name></TestPerson35></people></TestArray35>", xml); }
public void should_be_able_to_get_properties() { int id = 2; XStream xs = new XStream(); xs.Alias <TestPerson35>("person"); var person = new TestPerson35 { ID = id }; string xml = xs.ToXml(person); Assert.IsTrue(xml.Contains("<ID>2</ID>")); }
public void should_serialize_a_generic_list() { XStream xs = new XStream(); xs.Alias <TestPeople35>("TestPeople"); xs.Alias <TestPerson35>("TestPerson"); TestPeople35 ppl = new TestPeople35(); TestPerson35 person = new TestPerson35(); person.ID = 12; person.Name = "Joe"; ppl.People.Add(person); //ppl.people1 = new[] {person}; string xml = xs.ToXml(ppl); Assert.AreEqual("<TestPeople><People><TestPerson><ID>12</ID><Name>Joe</Name></TestPerson></People></TestPeople>", xml); }