summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.Test/OpenId/Extensions/AttributeExchange/StoreRequestTests.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/DotNetOpenAuth.Test/OpenId/Extensions/AttributeExchange/StoreRequestTests.cs')
-rw-r--r--src/DotNetOpenAuth.Test/OpenId/Extensions/AttributeExchange/StoreRequestTests.cs70
1 files changed, 70 insertions, 0 deletions
diff --git a/src/DotNetOpenAuth.Test/OpenId/Extensions/AttributeExchange/StoreRequestTests.cs b/src/DotNetOpenAuth.Test/OpenId/Extensions/AttributeExchange/StoreRequestTests.cs
new file mode 100644
index 0000000..e0fe064
--- /dev/null
+++ b/src/DotNetOpenAuth.Test/OpenId/Extensions/AttributeExchange/StoreRequestTests.cs
@@ -0,0 +1,70 @@
+//-----------------------------------------------------------------------
+// <copyright file="StoreRequestTests.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOpenAuth.Test.OpenId.Extensions.AttributeExchange {
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Text;
+ using DotNetOpenAuth.Messaging;
+ using DotNetOpenAuth.OpenId.Extensions.AttributeExchange;
+ using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+ [TestClass]
+ public class StoreRequestTests {
+ /// <summary>
+ /// Verifies the constructor behavior.
+ /// </summary>
+ [TestMethod]
+ public void Ctor() {
+ var req = new StoreRequest();
+ Assert.IsFalse(req.Attributes.Any());
+ }
+
+ /// <summary>
+ /// Verifies the AddAttribute method.
+ /// </summary>
+ [TestMethod]
+ public void AddAttributeByValue() {
+ var req = new StoreRequest();
+ AttributeValues value = new AttributeValues();
+ req.AddAttribute(value);
+ Assert.AreSame(value, req.Attributes.Single());
+ }
+
+ /// <summary>
+ /// Verifies the AddAttribute method.
+ /// </summary>
+ [TestMethod]
+ public void AddAttributeByPrimitives() {
+ var req = new StoreRequest();
+ req.AddAttribute("http://att1", "value1", "value2");
+ AttributeValues value = req.Attributes.Single();
+ Assert.AreEqual("http://att1", value.TypeUri);
+ Assert.IsTrue(MessagingUtilities.AreEquivalent(new[] { "value1", "value2" }, value.Values));
+ }
+
+ /// <summary>
+ /// Verifies the Equals method.
+ /// </summary>
+ [TestMethod]
+ public void EqualityTests() {
+ var req1 = new StoreRequest();
+ var req2 = new StoreRequest();
+ Assert.AreEqual(req1, req2);
+
+ // Add attributes in different orders deliberately.
+ req1.AddAttribute("http://att1");
+ Assert.AreNotEqual(req1, req2);
+ req2.AddAttribute("http://att2");
+ Assert.AreNotEqual(req1, req2);
+ req1.AddAttribute("http://att2");
+ Assert.AreNotEqual(req1, req2);
+ req2.AddAttribute("http://att1");
+ Assert.AreEqual(req1, req2);
+ }
+ }
+}