summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.Test/OpenId/IdentifierTests.cs
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2008-11-23 23:04:56 -0800
committerAndrew <andrewarnott@gmail.com>2008-11-23 23:04:56 -0800
commite81621138e95624e12db5667c5720cde1f0475d9 (patch)
tree80a8ca1fe36611b99ef790801d90922f489d4aad /src/DotNetOpenAuth.Test/OpenId/IdentifierTests.cs
parent87af9a2cf5efade047cef5966d6d05fc40592a85 (diff)
downloadDotNetOpenAuth-e81621138e95624e12db5667c5720cde1f0475d9.zip
DotNetOpenAuth-e81621138e95624e12db5667c5720cde1f0475d9.tar.gz
DotNetOpenAuth-e81621138e95624e12db5667c5720cde1f0475d9.tar.bz2
Added YADIS and other discovery, XRDS, untrusted web requests.
Hundreds of StyleCop messages and some FxCop as well. Some refactoring definitely went into the new files from their DotNetOpenId origins, but there is much more to do.
Diffstat (limited to 'src/DotNetOpenAuth.Test/OpenId/IdentifierTests.cs')
-rw-r--r--src/DotNetOpenAuth.Test/OpenId/IdentifierTests.cs66
1 files changed, 66 insertions, 0 deletions
diff --git a/src/DotNetOpenAuth.Test/OpenId/IdentifierTests.cs b/src/DotNetOpenAuth.Test/OpenId/IdentifierTests.cs
new file mode 100644
index 0000000..8c3bc3b
--- /dev/null
+++ b/src/DotNetOpenAuth.Test/OpenId/IdentifierTests.cs
@@ -0,0 +1,66 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using DotNetOpenAuth.OpenId;
+
+namespace DotNetOpenAuth.Test.OpenId {
+ [TestClass]
+ public class IdentifierTests {
+ string uri = "http://www.yahoo.com/";
+ string uriNoScheme = "www.yahoo.com";
+ string uriHttps = "https://www.yahoo.com/";
+ string xri = "=arnott*andrew";
+
+ [TestMethod]
+ public void Parse() {
+ Assert.IsInstanceOfType(typeof(UriIdentifier), Identifier.Parse(uri));
+ Assert.IsInstanceOfType(typeof(XriIdentifier), Identifier.Parse(xri));
+ }
+
+ /// <summary>
+ /// Tests conformance with 2.0 spec section 7.2#2
+ /// </summary>
+ [TestMethod]
+ public void ParseEndUserSuppliedXriIdentifer() {
+ List<char> symbols = new List<char>(XriIdentifier.GlobalContextSymbols);
+ symbols.Add('(');
+ List<string> prefixes = new List<string>();
+ prefixes.AddRange(symbols.Select(s => s.ToString()));
+ prefixes.AddRange(symbols.Select(s => "xri://" + s.ToString()));
+ foreach (string prefix in prefixes) {
+ var id = Identifier.Parse(prefix + "andrew");
+ Assert.IsInstanceOfType(typeof(XriIdentifier), id);
+ }
+ }
+
+ /// <summary>
+ /// Verifies conformance with 2.0 spec section 7.2#3
+ /// </summary>
+ [TestMethod]
+ public void ParseEndUserSuppliedUriIdentifier() {
+ // verify a fully-qualified Uri
+ var id = Identifier.Parse(uri);
+ Assert.IsInstanceOfType(typeof(UriIdentifier), id);
+ Assert.AreEqual(uri, ((UriIdentifier)id).Uri.AbsoluteUri);
+ // verify an HTTPS Uri
+ id = Identifier.Parse(uriHttps);
+ Assert.IsInstanceOfType(typeof(UriIdentifier), id);
+ Assert.AreEqual(uriHttps, ((UriIdentifier)id).Uri.AbsoluteUri);
+ // verify that if the scheme is missing it is added automatically
+ id = Identifier.Parse(uriNoScheme);
+ Assert.IsInstanceOfType(typeof(UriIdentifier), id);
+ Assert.AreEqual(uri, ((UriIdentifier)id).Uri.AbsoluteUri);
+ }
+
+ [TestMethod, ExpectedException(typeof(ArgumentNullException))]
+ public void ParseNull() {
+ Identifier.Parse(null);
+ }
+
+ [TestMethod, ExpectedException(typeof(ArgumentNullException))]
+ public void ParseEmpty() {
+ Identifier.Parse(string.Empty);
+ }
+ }
+}