diff options
Diffstat (limited to 'src/DotNetOpenId.Test/Extensions/SimpleRegistrationTests.cs')
-rw-r--r-- | src/DotNetOpenId.Test/Extensions/SimpleRegistrationTests.cs | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/src/DotNetOpenId.Test/Extensions/SimpleRegistrationTests.cs b/src/DotNetOpenId.Test/Extensions/SimpleRegistrationTests.cs index 9437f27..f08a047 100644 --- a/src/DotNetOpenId.Test/Extensions/SimpleRegistrationTests.cs +++ b/src/DotNetOpenId.Test/Extensions/SimpleRegistrationTests.cs @@ -1,9 +1,10 @@ using System;
using System.Collections.Generic;
+using System.Globalization;
using System.Linq;
using System.Text;
-using NUnit.Framework;
using DotNetOpenId.Extensions.SimpleRegistration;
+using NUnit.Framework;
namespace DotNetOpenId.Test.Extensions {
[TestFixture]
@@ -35,5 +36,40 @@ namespace DotNetOpenId.Test.Extensions { Assert.IsNull(response.FullName);
Assert.AreEqual("andrewarnott@gmail.com", response.Email);
}
+
+ [Test]
+ public void Birthdates() {
+ var response = new ClaimsResponse();
+ // Verify that they both start out as null
+ Assert.IsNull(response.BirthDateRaw);
+ Assert.IsFalse(response.BirthDate.HasValue);
+
+ // Verify that null can be set.
+ response.BirthDate = null;
+ response.BirthDateRaw = null;
+ Assert.IsNull(response.BirthDateRaw);
+ Assert.IsFalse(response.BirthDate.HasValue);
+
+ // Verify that the strong-typed BirthDate property can be set and that it affects the raw property.
+ response.BirthDate = DateTime.Parse("April 4, 1984");
+ Assert.AreEqual(4, response.BirthDate.Value.Month);
+ Assert.AreEqual("1984-04-04", response.BirthDateRaw);
+
+ // Verify that the raw property can be set with a complete birthdate and that it affects the strong-typed property.
+ response.BirthDateRaw = "1998-05-08";
+ Assert.AreEqual("1998-05-08", response.BirthDateRaw);
+ Assert.AreEqual(DateTime.Parse("May 8, 1998", CultureInfo.InvariantCulture), response.BirthDate);
+
+ // Verify that an partial raw birthdate works, and sets the strong-typed property to null since it cannot be represented.
+ response.BirthDateRaw = "2000-00-00";
+ Assert.AreEqual("2000-00-00", response.BirthDateRaw);
+ Assert.IsFalse(response.BirthDate.HasValue);
+ }
+
+ [Test, ExpectedException(typeof(ArgumentException))]
+ public void InvalidRawBirthdate() {
+ var response = new ClaimsResponse();
+ response.BirthDateRaw = "2008";
+ }
}
}
|