diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2009-04-07 08:21:55 -0700 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2009-04-07 08:21:55 -0700 |
commit | 191c7e7852f2c91a2da960f0ee08c635df8347bb (patch) | |
tree | 7bee0d2f5774d95a363bb7176bfc4d697aacf57f /src | |
parent | fb3cf920e3d05d699ef7acc91d127e199b46a8da (diff) | |
download | DotNetOpenAuth-191c7e7852f2c91a2da960f0ee08c635df8347bb.zip DotNetOpenAuth-191c7e7852f2c91a2da960f0ee08c635df8347bb.tar.gz DotNetOpenAuth-191c7e7852f2c91a2da960f0ee08c635df8347bb.tar.bz2 |
Fixed bug where AX extensions were not serializable, and added unit tests to verify.
Diffstat (limited to 'src')
5 files changed, 66 insertions, 0 deletions
diff --git a/src/DotNetOpenAuth.Test/OpenId/Extensions/AttributeExchange/FetchRequestTests.cs b/src/DotNetOpenAuth.Test/OpenId/Extensions/AttributeExchange/FetchRequestTests.cs index 4dbb5ad..43eba3f 100644 --- a/src/DotNetOpenAuth.Test/OpenId/Extensions/AttributeExchange/FetchRequestTests.cs +++ b/src/DotNetOpenAuth.Test/OpenId/Extensions/AttributeExchange/FetchRequestTests.cs @@ -6,6 +6,7 @@ namespace DotNetOpenAuth.Test.OpenId.Extensions { using System; + using System.IO; using DotNetOpenAuth.OpenId.Extensions.AttributeExchange; using DotNetOpenAuth.Test.OpenId; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -95,5 +96,20 @@ namespace DotNetOpenAuth.Test.OpenId.Extensions { req2.Attributes.Add(new AttributeRequest("http://att1")); Assert.AreEqual(req1, req2); } + + /// <summary> + /// Verifies that the class is serializable. + /// </summary> + [TestMethod] + public void Serializable() { + var fetch = new FetchRequest(); + fetch.Attributes.AddRequired("http://someAttribute"); + var formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); + var ms = new MemoryStream(); + formatter.Serialize(ms, fetch); + ms.Position = 0; + var fetch2 = formatter.Deserialize(ms); + Assert.AreEqual(fetch, fetch2); + } } } diff --git a/src/DotNetOpenAuth.Test/OpenId/Extensions/AttributeExchange/FetchResponseTests.cs b/src/DotNetOpenAuth.Test/OpenId/Extensions/AttributeExchange/FetchResponseTests.cs index 32e723a..d467186 100644 --- a/src/DotNetOpenAuth.Test/OpenId/Extensions/AttributeExchange/FetchResponseTests.cs +++ b/src/DotNetOpenAuth.Test/OpenId/Extensions/AttributeExchange/FetchResponseTests.cs @@ -6,6 +6,7 @@ namespace DotNetOpenId.Test.OpenId.Extensions { using System; + using System.IO; using DotNetOpenAuth.OpenId.Extensions.AttributeExchange; using DotNetOpenAuth.Test.OpenId; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -59,5 +60,20 @@ namespace DotNetOpenId.Test.OpenId.Extensions { response2.Attributes.Add(new AttributeValues("http://att1")); Assert.AreEqual(response1, response2); } + + /// <summary> + /// Verifies that the class is serializable. + /// </summary> + [TestMethod] + public void Serializable() { + var fetch = new FetchResponse(); + fetch.Attributes.Add("http://someAttribute", "val1", "val2"); + var formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); + var ms = new MemoryStream(); + formatter.Serialize(ms, fetch); + ms.Position = 0; + var fetch2 = formatter.Deserialize(ms); + Assert.AreEqual(fetch, fetch2); + } } } diff --git a/src/DotNetOpenAuth.Test/OpenId/Extensions/AttributeExchange/StoreRequestTests.cs b/src/DotNetOpenAuth.Test/OpenId/Extensions/AttributeExchange/StoreRequestTests.cs index 23c9177..b11c469 100644 --- a/src/DotNetOpenAuth.Test/OpenId/Extensions/AttributeExchange/StoreRequestTests.cs +++ b/src/DotNetOpenAuth.Test/OpenId/Extensions/AttributeExchange/StoreRequestTests.cs @@ -7,6 +7,7 @@ namespace DotNetOpenAuth.Test.OpenId.Extensions.AttributeExchange { using System; using System.Collections.Generic; + using System.IO; using System.Linq; using System.Text; using DotNetOpenAuth.Messaging; @@ -66,5 +67,20 @@ namespace DotNetOpenAuth.Test.OpenId.Extensions.AttributeExchange { req2.Attributes.Add("http://att1"); Assert.AreEqual(req1, req2); } + + /// <summary> + /// Verifies that the class is serializable. + /// </summary> + [TestMethod] + public void Serializable() { + var store = new StoreRequest(); + store.Attributes.Add("http://someAttribute", "val1", "val2"); + var formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); + var ms = new MemoryStream(); + formatter.Serialize(ms, store); + ms.Position = 0; + var store2 = formatter.Deserialize(ms); + Assert.AreEqual(store, store2); + } } } diff --git a/src/DotNetOpenAuth.Test/OpenId/Extensions/AttributeExchange/StoreResponseTests.cs b/src/DotNetOpenAuth.Test/OpenId/Extensions/AttributeExchange/StoreResponseTests.cs index 5dab1b7..4e432e1 100644 --- a/src/DotNetOpenAuth.Test/OpenId/Extensions/AttributeExchange/StoreResponseTests.cs +++ b/src/DotNetOpenAuth.Test/OpenId/Extensions/AttributeExchange/StoreResponseTests.cs @@ -5,6 +5,7 @@ //----------------------------------------------------------------------- namespace DotNetOpenAuth.Test.OpenId.Extensions.AttributeExchange { + using System.IO; using DotNetOpenAuth.OpenId.Extensions.AttributeExchange; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -46,5 +47,21 @@ namespace DotNetOpenAuth.Test.OpenId.Extensions.AttributeExchange { response2.FailureReason = "bad code"; Assert.AreEqual(response1, response2); } + + /// <summary> + /// Verifies that the class is serializable. + /// </summary> + [TestMethod] + public void Serializable() { + var store = new StoreResponse(); + store.Succeeded = false; + store.FailureReason = "some reason"; + var formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); + var ms = new MemoryStream(); + formatter.Serialize(ms, store); + ms.Position = 0; + var store2 = formatter.Deserialize(ms); + Assert.AreEqual(store, store2); + } } } diff --git a/src/DotNetOpenAuth/Messaging/KeyedCollectionDelegate.cs b/src/DotNetOpenAuth/Messaging/KeyedCollectionDelegate.cs index 928f873..16786e3 100644 --- a/src/DotNetOpenAuth/Messaging/KeyedCollectionDelegate.cs +++ b/src/DotNetOpenAuth/Messaging/KeyedCollectionDelegate.cs @@ -15,6 +15,7 @@ namespace DotNetOpenAuth.Messaging { /// </summary> /// <typeparam name="TKey">The type of the key.</typeparam> /// <typeparam name="TItem">The type of the item.</typeparam> + [Serializable] internal class KeyedCollectionDelegate<TKey, TItem> : KeyedCollection<TKey, TItem> { /// <summary> /// The delegate that returns a key for the given item. |