diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2008-09-18 16:17:42 -0700 |
---|---|---|
committer | Andrew <andrewarnott@gmail.com> | 2008-09-18 16:17:42 -0700 |
commit | 11615a19bad90741c7a755eaf741b8683992c9ff (patch) | |
tree | 5ad7b033a81cf74192e31d496bdeb76401a6af44 /src/DotNetOAuth.Test/Messaging/Reflection/MessagePartTests.cs | |
parent | 95e418aa02296a93587c4e07b0f3eec8cd379416 (diff) | |
download | DotNetOpenAuth-11615a19bad90741c7a755eaf741b8683992c9ff.zip DotNetOpenAuth-11615a19bad90741c7a755eaf741b8683992c9ff.tar.gz DotNetOpenAuth-11615a19bad90741c7a755eaf741b8683992c9ff.tar.bz2 |
Fixed a few bugs and got all tests passing.
Diffstat (limited to 'src/DotNetOAuth.Test/Messaging/Reflection/MessagePartTests.cs')
-rw-r--r-- | src/DotNetOAuth.Test/Messaging/Reflection/MessagePartTests.cs | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/DotNetOAuth.Test/Messaging/Reflection/MessagePartTests.cs b/src/DotNetOAuth.Test/Messaging/Reflection/MessagePartTests.cs index 646599c..1d7e1b8 100644 --- a/src/DotNetOAuth.Test/Messaging/Reflection/MessagePartTests.cs +++ b/src/DotNetOAuth.Test/Messaging/Reflection/MessagePartTests.cs @@ -16,12 +16,29 @@ namespace DotNetOAuth.Test.Messaging.Reflection { [MessagePart(IsRequired = false)]
internal int optionalInt;
}
+ class MessageWithNullableOptionalStruct {
+ /// <summary>
+ /// Optional structs like int must be nullable for Optional to make sense.
+ /// </summary>
+ [MessagePart(IsRequired = false)]
+ internal int? optionalInt;
+ }
+
[TestMethod, ExpectedException(typeof(ArgumentException))]
public void OptionalNonNullableStruct() {
- FieldInfo field = typeof(MessageWithNonNullableOptionalStruct).GetField("optionalInt", BindingFlags.NonPublic | BindingFlags.Instance);
+ ParameterizedMessageTypeTest(typeof(MessageWithNonNullableOptionalStruct));
+ }
+
+ [TestMethod]
+ public void OptionalNullableStruct() {
+ ParameterizedMessageTypeTest(typeof(MessageWithNullableOptionalStruct));
+ }
+
+ private void ParameterizedMessageTypeTest(Type messageType) {
+ FieldInfo field = messageType.GetField("optionalInt", BindingFlags.NonPublic | BindingFlags.Instance);
MessagePartAttribute attribute = field.GetCustomAttributes(typeof(MessagePartAttribute), true).OfType<MessagePartAttribute>().Single();
- new MessagePart(field, attribute); // should recognize invalid optional non-nullable struct
+ new MessagePart(field, attribute);
}
}
}
|