public void TestDeserialization() { string serData = @"<?xml version=""1.0"" encoding=""iso-8859-1""?> <!DOCTYPE nzb PUBLIC ""-//newzBin//DTD NZB 1.1//EN"" ""http://www.newzbin.com/DTD/nzb/nzb-1.1.dtd""> <nzb xmlns=""http://www.newzbin.com/DTD/2003/nzb""> <head> <meta type=""title"">title test</meta> <meta type=""tag"">tag test</meta> </head> <file poster=""Joe"" date=""1289916507.2150896"" subject=""Sujet de Joe""><groups><group>alt.binaries.newzbin</group><group>alt.binaries.mojo</group></groups><segments><segment bytes=""102394"" number=""1"">[email protected]</segment><segment bytes=""4501"" number=""2"">[email protected]</segment></segments></file></nzb>"; NZBDocument nzbdoc = new NZBDocument(serData, ReferenceType.SerializedData); Assert.IsNotNull(nzbdoc); Assert.IsNotNull(nzbdoc.File); Assert.True(nzbdoc.File.Length == 1); Assert.IsNotNull(nzbdoc.Head); Assert.True(nzbdoc.Head.Length == 2); }
public void TestSerialization() { NZBDocument nzbDoc = new NZBDocument() { Head = new NZBMeta[] { new NZBMeta() { Data = "title test", Type = NZBMetaType.Title }, new NZBMeta() { Data = "tag test", Type = NZBMetaType.Tag } }, File = new NZBFile[] { new NZBFile() { Date = Math.Round((DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds, 0), Poster = "Joe", Subject = "Sujet de Joe", Groups = new string[] { "alt.binaries.newzbin", "alt.binaries.mojo" }, Segments = new NZBSegment[] { new NZBSegment() { Bytes = 102394 , Number = 1 , Data = "*****@*****.**" }, new NZBSegment() { Bytes = 4501 , Number = 2 , Data = "*****@*****.**" } } } } }; Assert.IsNotNullOrEmpty(nzbDoc.Serialize()); }