public void Typical_Entry() { var xml = @"<entry xmlns=""http://www.w3.org/2005/Atom"" xmlns:sync=""http://schemas.sage.com/sdata/sync/2008/1""> <sync:syncState> <sync:endpoint>http://www.example.com/sdata/myApp1/myContract/-/accounts</sync:endpoint> <sync:tick>5</sync:tick> <sync:stamp>2008-10-30T14:55:43Z</sync:stamp> </sync:syncState> </entry>"; var entry = new AtomEntry(); using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(xml))) { entry.Load(stream); } var syncState = entry.GetSDataSyncState(); Assert.That(syncState.EndPoint, Is.EqualTo("http://www.example.com/sdata/myApp1/myContract/-/accounts")); Assert.That(syncState.Tick, Is.EqualTo(5L)); Assert.That(syncState.Stamp, Is.EqualTo(new DateTime(2008, 10, 30, 14, 55, 43))); }
private static AtomEntry LoadEntryContent(Stream stream) { var entry = new AtomEntry(); entry.Load(stream); return entry; }
/// <summary> /// Creates a new <see cref="AtomEntry"/> instance using the specified <see cref="Uri"/>, <see cref="ICredentials"/>, <see cref="IWebProxy"/>, and <see cref="SyndicationResourceLoadSettings"/> object. /// </summary> /// <param name="source">A <see cref="Uri"/> that represents the URL of the syndication resource XML data.</param> /// <param name="options">A <see cref="WebRequestOptions"/> that holds options that should be applied to web requests.</param> /// <param name="settings">The <see cref="SyndicationResourceLoadSettings"/> object used to configure the <see cref="AtomEntry"/> instance. This value can be <b>null</b>.</param> /// <returns>An <see cref="AtomEntry"/> object loaded using the <paramref name="source"/> data.</returns> /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception> /// <exception cref="FormatException">The <paramref name="source"/> data does not conform to the expected syndication content format. In this case, the entry remains empty.</exception> public static AtomEntry Create(Uri source, WebRequestOptions options, SyndicationResourceLoadSettings settings) { //------------------------------------------------------------ // Local members //------------------------------------------------------------ AtomEntry syndicationResource = new AtomEntry(); //------------------------------------------------------------ // Validate parameters //------------------------------------------------------------ Guard.ArgumentNotNull(source, "source"); //------------------------------------------------------------ // Create new instance using supplied parameters //------------------------------------------------------------ syndicationResource.Load(source, options, settings); return syndicationResource; }