summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.Test/Messaging/Reflection
diff options
context:
space:
mode:
Diffstat (limited to 'src/DotNetOpenAuth.Test/Messaging/Reflection')
-rw-r--r--src/DotNetOpenAuth.Test/Messaging/Reflection/MessageDescriptionTests.cs12
-rw-r--r--src/DotNetOpenAuth.Test/Messaging/Reflection/MessageDictionaryTests.cs52
-rw-r--r--src/DotNetOpenAuth.Test/Messaging/Reflection/MessagePartTests.cs37
-rw-r--r--src/DotNetOpenAuth.Test/Messaging/Reflection/ValueMappingTests.cs12
4 files changed, 59 insertions, 54 deletions
diff --git a/src/DotNetOpenAuth.Test/Messaging/Reflection/MessageDescriptionTests.cs b/src/DotNetOpenAuth.Test/Messaging/Reflection/MessageDescriptionTests.cs
index 76c454a..e57df65 100644
--- a/src/DotNetOpenAuth.Test/Messaging/Reflection/MessageDescriptionTests.cs
+++ b/src/DotNetOpenAuth.Test/Messaging/Reflection/MessageDescriptionTests.cs
@@ -8,26 +8,26 @@ namespace DotNetOpenAuth.Test.Messaging.Reflection {
using System;
using DotNetOpenAuth.Messaging;
using DotNetOpenAuth.Messaging.Reflection;
- using Microsoft.VisualStudio.TestTools.UnitTesting;
+ using NUnit.Framework;
- [TestClass]
+ [TestFixture]
public class MessageDescriptionTests : MessagingTestBase {
- [TestMethod, ExpectedException(typeof(ArgumentNullException))]
+ [TestCase, ExpectedException(typeof(ArgumentNullException))]
public void CtorNullType() {
new MessageDescription(null, new Version(1, 0));
}
- [TestMethod, ExpectedException(typeof(ArgumentNullException))]
+ [TestCase, ExpectedException(typeof(ArgumentNullException))]
public void CtorNullVersion() {
new MessageDescription(typeof(Mocks.TestMessage), null);
}
- [TestMethod, ExpectedException(typeof(ArgumentException))]
+ [TestCase, ExpectedException(typeof(ArgumentException))]
public void CtorNonMessageType() {
new MessageDescription(typeof(string), new Version(1, 0));
}
- [TestMethod]
+ [TestCase]
public void MultiVersionedMessageTest() {
var v10 = new MessageDescription(typeof(MultiVersionMessage), new Version(1, 0));
var v20 = new MessageDescription(typeof(MultiVersionMessage), new Version(2, 0));
diff --git a/src/DotNetOpenAuth.Test/Messaging/Reflection/MessageDictionaryTests.cs b/src/DotNetOpenAuth.Test/Messaging/Reflection/MessageDictionaryTests.cs
index b9e7436..9e3f4c5 100644
--- a/src/DotNetOpenAuth.Test/Messaging/Reflection/MessageDictionaryTests.cs
+++ b/src/DotNetOpenAuth.Test/Messaging/Reflection/MessageDictionaryTests.cs
@@ -12,20 +12,20 @@ namespace DotNetOpenAuth.Test.Messaging.Reflection {
using System.Xml;
using DotNetOpenAuth.Messaging;
using DotNetOpenAuth.Messaging.Reflection;
- using Microsoft.VisualStudio.TestTools.UnitTesting;
+ using NUnit.Framework;
- [TestClass]
+ [TestFixture]
public class MessageDictionaryTests : MessagingTestBase {
private Mocks.TestMessage message;
- [TestInitialize]
+ [SetUp]
public override void SetUp() {
base.SetUp();
this.message = new Mocks.TestDirectedMessage();
}
- [TestMethod, ExpectedException(typeof(ArgumentNullException))]
+ [TestCase, ExpectedException(typeof(ArgumentNullException))]
public void CtorNull() {
this.MessageDescriptions.GetAccessor(null);
}
@@ -33,7 +33,7 @@ namespace DotNetOpenAuth.Test.Messaging.Reflection {
/// <summary>
/// A test for System.Collections.Generic.IDictionary&lt;System.String,System.String>.Values
/// </summary>
- [TestMethod]
+ [TestCase]
public void Values() {
IDictionary<string, string> target = this.MessageDescriptions.GetAccessor(this.message);
Collection<string> expected = new Collection<string> {
@@ -59,7 +59,7 @@ namespace DotNetOpenAuth.Test.Messaging.Reflection {
/// <summary>
/// A test for System.Collections.Generic.IDictionary&lt;System.String,System.String>.Keys
/// </summary>
- [TestMethod]
+ [TestCase]
public void Keys() {
// We expect that non-nullable value type fields will automatically have keys
// in the dictionary for them.
@@ -80,7 +80,7 @@ namespace DotNetOpenAuth.Test.Messaging.Reflection {
/// <summary>
/// A test for System.Collections.Generic.IDictionary&lt;System.String,System.String>.Item
/// </summary>
- [TestMethod]
+ [TestCase]
public void Item() {
IDictionary<string, string> target = this.MessageDescriptions.GetAccessor(this.message);
@@ -103,7 +103,7 @@ namespace DotNetOpenAuth.Test.Messaging.Reflection {
/// <summary>
/// A test for System.Collections.Generic.ICollection&lt;System.Collections.Generic.KeyValuePair&lt;System.String,System.String&lt;&lt;.IsReadOnly
/// </summary>
- [TestMethod]
+ [TestCase]
public void IsReadOnly() {
ICollection<KeyValuePair<string, string>> target = this.MessageDescriptions.GetAccessor(this.message);
Assert.IsFalse(target.IsReadOnly);
@@ -112,7 +112,7 @@ namespace DotNetOpenAuth.Test.Messaging.Reflection {
/// <summary>
/// A test for System.Collections.Generic.ICollection&lt;System.Collections.Generic.KeyValuePair&lt;System.String,System.String&lt;&lt;.Count
/// </summary>
- [TestMethod]
+ [TestCase]
public void Count() {
ICollection<KeyValuePair<string, string>> target = this.MessageDescriptions.GetAccessor(this.message);
IDictionary<string, string> targetDictionary = (IDictionary<string, string>)target;
@@ -124,7 +124,7 @@ namespace DotNetOpenAuth.Test.Messaging.Reflection {
/// <summary>
/// A test for System.Collections.Generic.IEnumerable&lt;System.Collections.Generic.KeyValuePair&lt;System.String,System.String&lt;&lt;.GetEnumerator
/// </summary>
- [TestMethod]
+ [TestCase]
public void GetEnumerator() {
IEnumerable<KeyValuePair<string, string>> target = this.MessageDescriptions.GetAccessor(this.message);
IDictionary<string, string> targetDictionary = (IDictionary<string, string>)target;
@@ -147,7 +147,7 @@ namespace DotNetOpenAuth.Test.Messaging.Reflection {
Assert.IsTrue(keysLast == valuesLast && keysLast == actualLast);
}
- [TestMethod]
+ [TestCase]
public void GetEnumeratorUntyped() {
IEnumerable target = this.MessageDescriptions.GetAccessor(this.message);
IDictionary<string, string> targetDictionary = (IDictionary<string, string>)target;
@@ -174,7 +174,7 @@ namespace DotNetOpenAuth.Test.Messaging.Reflection {
/// <summary>
/// A test for System.Collections.Generic.IDictionary&lt;System.String,System.String>.TryGetValue
/// </summary>
- [TestMethod]
+ [TestCase]
public void TryGetValue() {
IDictionary<string, string> target = this.MessageDescriptions.GetAccessor(this.message);
this.message.Name = "andrew";
@@ -194,7 +194,7 @@ namespace DotNetOpenAuth.Test.Messaging.Reflection {
/// <summary>
/// A test for System.Collections.Generic.IDictionary&lt;System.String,System.String>.Remove
/// </summary>
- [TestMethod]
+ [TestCase]
public void RemoveTest1() {
IDictionary<string, string> target = this.MessageDescriptions.GetAccessor(this.message);
this.message.Name = "andrew";
@@ -211,7 +211,7 @@ namespace DotNetOpenAuth.Test.Messaging.Reflection {
/// <summary>
/// A test for System.Collections.Generic.IDictionary&lt;System.String,System.String>.ContainsKey
/// </summary>
- [TestMethod]
+ [TestCase]
public void ContainsKey() {
IDictionary<string, string> target = this.MessageDescriptions.GetAccessor(this.message);
Assert.IsTrue(target.ContainsKey("age"), "Value type declared element should have a key.");
@@ -225,7 +225,7 @@ namespace DotNetOpenAuth.Test.Messaging.Reflection {
/// <summary>
/// A test for System.Collections.Generic.IDictionary&lt;System.String,System.String&gt;.Add
/// </summary>
- [TestMethod]
+ [TestCase]
public void AddByKeyAndValue() {
IDictionary<string, string> target = this.MessageDescriptions.GetAccessor(this.message);
target.Add("extra", "value");
@@ -234,7 +234,7 @@ namespace DotNetOpenAuth.Test.Messaging.Reflection {
Assert.AreEqual("Andrew", this.message.Name);
}
- [TestMethod, ExpectedException(typeof(ArgumentNullException))]
+ [TestCase, ExpectedException(typeof(ArgumentNullException))]
public void AddNullValue() {
IDictionary<string, string> target = this.MessageDescriptions.GetAccessor(this.message);
target.Add("extra", null);
@@ -243,35 +243,35 @@ namespace DotNetOpenAuth.Test.Messaging.Reflection {
/// <summary>
/// A test for System.Collections.Generic.ICollection&lt;System.Collections.Generic.KeyValuePair&lt;System.String,System.String&lt;&lt;.Add
/// </summary>
- [TestMethod]
+ [TestCase]
public void AddByKeyValuePair() {
IDictionary<string, string> target = this.MessageDescriptions.GetAccessor(this.message);
target.Add(new KeyValuePair<string, string>("extra", "value"));
Assert.IsTrue(target.Contains(new KeyValuePair<string, string>("extra", "value")));
}
- [TestMethod, ExpectedException(typeof(ArgumentException))]
+ [TestCase, ExpectedException(typeof(ArgumentException))]
public void AddExtraFieldThatAlreadyExists() {
IDictionary<string, string> target = this.MessageDescriptions.GetAccessor(this.message);
target.Add("extra", "value");
target.Add("extra", "value");
}
- [TestMethod, ExpectedException(typeof(ArgumentException))]
+ [TestCase, ExpectedException(typeof(ArgumentException))]
public void AddDeclaredValueThatAlreadyExists() {
IDictionary<string, string> target = this.MessageDescriptions.GetAccessor(this.message);
target.Add("Name", "andrew");
target.Add("Name", "andrew");
}
- [TestMethod]
+ [TestCase]
public void DefaultReferenceTypeDeclaredPropertyHasNoKey() {
IDictionary<string, string> target = this.MessageDescriptions.GetAccessor(this.message);
Assert.IsFalse(target.ContainsKey("Name"), "A null value should result in no key.");
Assert.IsFalse(target.Keys.Contains("Name"), "A null value should result in no key.");
}
- [TestMethod]
+ [TestCase]
public void RemoveStructDeclaredProperty() {
IDictionary<string, string> target = this.MessageDescriptions.GetAccessor(this.message);
this.message.Age = 5;
@@ -284,7 +284,7 @@ namespace DotNetOpenAuth.Test.Messaging.Reflection {
/// <summary>
/// A test for System.Collections.Generic.ICollection&lt;System.Collections.Generic.KeyValuePair&lt;System.String,System.String&lt;&lt;.Remove
/// </summary>
- [TestMethod]
+ [TestCase]
public void RemoveByKeyValuePair() {
ICollection<KeyValuePair<string, string>> target = this.MessageDescriptions.GetAccessor(this.message);
this.message.Name = "Andrew";
@@ -297,7 +297,7 @@ namespace DotNetOpenAuth.Test.Messaging.Reflection {
/// <summary>
/// A test for System.Collections.Generic.ICollection&lt;System.Collections.Generic.KeyValuePair&lt;System.String,System.String&lt;&lt;.CopyTo
/// </summary>
- [TestMethod]
+ [TestCase]
public void CopyTo() {
ICollection<KeyValuePair<string, string>> target = this.MessageDescriptions.GetAccessor(this.message);
IDictionary<string, string> targetAsDictionary = (IDictionary<string, string>)target;
@@ -314,7 +314,7 @@ namespace DotNetOpenAuth.Test.Messaging.Reflection {
/// <summary>
/// A test for System.Collections.Generic.ICollection&lt;System.Collections.Generic.KeyValuePair&lt;System.String,System.String&lt;&lt;.Contains
/// </summary>
- [TestMethod]
+ [TestCase]
public void ContainsKeyValuePair() {
ICollection<KeyValuePair<string, string>> target = this.MessageDescriptions.GetAccessor(this.message);
IDictionary<string, string> targetAsDictionary = (IDictionary<string, string>)target;
@@ -330,7 +330,7 @@ namespace DotNetOpenAuth.Test.Messaging.Reflection {
/// <summary>
/// A test for System.Collections.Generic.ICollection&lt;System.Collections.Generic.KeyValuePair&lt;System.String,System.String&lt;&lt;.Clear
/// </summary>
- [TestMethod]
+ [TestCase]
public void ClearValues() {
MessageDictionary target = this.MessageDescriptions.GetAccessor(this.message);
IDictionary<string, string> targetAsDictionary = (IDictionary<string, string>)target;
@@ -347,7 +347,7 @@ namespace DotNetOpenAuth.Test.Messaging.Reflection {
/// <summary>
/// Verifies that the Clear method throws the expected exception.
/// </summary>
- [TestMethod, ExpectedException(typeof(NotSupportedException))]
+ [TestCase, ExpectedException(typeof(NotSupportedException))]
public void Clear() {
MessageDictionary target = this.MessageDescriptions.GetAccessor(this.message);
target.Clear();
diff --git a/src/DotNetOpenAuth.Test/Messaging/Reflection/MessagePartTests.cs b/src/DotNetOpenAuth.Test/Messaging/Reflection/MessagePartTests.cs
index 19e6a82..66237e7 100644
--- a/src/DotNetOpenAuth.Test/Messaging/Reflection/MessagePartTests.cs
+++ b/src/DotNetOpenAuth.Test/Messaging/Reflection/MessagePartTests.cs
@@ -12,42 +12,47 @@ namespace DotNetOpenAuth.Test.Messaging.Reflection {
using DotNetOpenAuth.Messaging;
using DotNetOpenAuth.Messaging.Reflection;
using DotNetOpenAuth.Test.Mocks;
- using Microsoft.VisualStudio.TestTools.UnitTesting;
+ using NUnit.Framework;
- [TestClass]
+ [TestFixture]
public class MessagePartTests : MessagingTestBase {
- [TestMethod, ExpectedException(typeof(ArgumentException))]
+ [TestCase, ExpectedException(typeof(ArgumentException))]
public void OptionalNonNullableStruct() {
this.ParameterizedMessageTypeTest(typeof(MessageWithNonNullableOptionalStruct));
}
- [TestMethod]
+ [TestCase]
public void RequiredNonNullableStruct() {
this.ParameterizedMessageTypeTest(typeof(MessageWithNonNullableRequiredStruct));
}
- [TestMethod]
+ [TestCase]
public void OptionalNullableStruct() {
- this.ParameterizedMessageTypeTest(typeof(MessageWithNullableOptionalStruct));
+ var message = new MessageWithNullableOptionalStruct();
+ var part = this.ParameterizedMessageTypeTest(message.GetType());
+
+ Assert.IsNull(part.GetValue(message));
+ part.SetValue(message, "3");
+ Assert.AreEqual("3", part.GetValue(message));
}
- [TestMethod]
+ [TestCase]
public void RequiredNullableStruct() {
this.ParameterizedMessageTypeTest(typeof(MessageWithNullableRequiredStruct));
}
- [TestMethod, ExpectedException(typeof(ArgumentNullException))]
+ [TestCase, ExpectedException(typeof(ArgumentNullException))]
public void CtorNullMember() {
new MessagePart(null, new MessagePartAttribute());
}
- [TestMethod, ExpectedException(typeof(ArgumentNullException))]
+ [TestCase, ExpectedException(typeof(ArgumentNullException))]
public void CtorNullAttribute() {
PropertyInfo field = typeof(MessageWithNullableOptionalStruct).GetProperty("OptionalInt", BindingFlags.NonPublic | BindingFlags.Instance);
new MessagePart(field, null);
}
- [TestMethod]
+ [TestCase]
public void SetValue() {
var message = new MessageWithNonNullableRequiredStruct();
MessagePart part = this.ParameterizedMessageTypeTest(message.GetType());
@@ -55,7 +60,7 @@ namespace DotNetOpenAuth.Test.Messaging.Reflection {
Assert.AreEqual(5, message.OptionalInt);
}
- [TestMethod]
+ [TestCase]
public void GetValue() {
var message = new MessageWithNonNullableRequiredStruct();
message.OptionalInt = 8;
@@ -63,7 +68,7 @@ namespace DotNetOpenAuth.Test.Messaging.Reflection {
Assert.AreEqual("8", part.GetValue(message));
}
- [TestMethod]
+ [TestCase]
public void Base64Member() {
var message = new MessageWithBase64EncodedString();
message.LastName = "andrew";
@@ -73,7 +78,7 @@ namespace DotNetOpenAuth.Test.Messaging.Reflection {
Assert.AreEqual("arnott", message.LastName);
}
- [TestMethod]
+ [TestCase]
public void ConstantFieldMemberValidValues() {
var message = new MessageWithConstantField();
MessagePart part = GetMessagePart(message.GetType(), "ConstantField");
@@ -82,20 +87,20 @@ namespace DotNetOpenAuth.Test.Messaging.Reflection {
Assert.AreEqual("abc", part.GetValue(message));
}
- [TestMethod, ExpectedException(typeof(ProtocolException))]
+ [TestCase, ExpectedException(typeof(ProtocolException))]
public void ConstantFieldMemberInvalidValues() {
var message = new MessageWithConstantField();
MessagePart part = GetMessagePart(message.GetType(), "ConstantField");
part.SetValue(message, "def");
}
- [TestMethod, ExpectedException(typeof(ArgumentException))]
+ [TestCase, ExpectedException(typeof(ArgumentException))]
public void NonFieldOrPropertyMember() {
MemberInfo method = typeof(MessageWithNullableOptionalStruct).GetMethod("Equals", BindingFlags.Public | BindingFlags.Instance);
new MessagePart(method, new MessagePartAttribute());
}
- [TestMethod]
+ [TestCase]
public void RequiredMinAndMaxVersions() {
Type messageType = typeof(MessageWithMinAndMaxVersionParts);
FieldInfo newIn2Field = messageType.GetField("NewIn2", BindingFlags.Public | BindingFlags.Instance);
diff --git a/src/DotNetOpenAuth.Test/Messaging/Reflection/ValueMappingTests.cs b/src/DotNetOpenAuth.Test/Messaging/Reflection/ValueMappingTests.cs
index c4a79b5..60c8bc3 100644
--- a/src/DotNetOpenAuth.Test/Messaging/Reflection/ValueMappingTests.cs
+++ b/src/DotNetOpenAuth.Test/Messaging/Reflection/ValueMappingTests.cs
@@ -7,18 +7,18 @@
namespace DotNetOpenAuth.Test.Messaging.Reflection {
using System;
using DotNetOpenAuth.Messaging.Reflection;
- using Microsoft.VisualStudio.TestTools.UnitTesting;
+ using NUnit.Framework;
- [TestClass]
+ [TestFixture]
public class ValueMappingTests {
- [TestMethod, ExpectedException(typeof(ArgumentNullException))]
+ [TestCase, ExpectedException(typeof(ArgumentNullException))]
public void CtorNullToString() {
- new ValueMapping(null, str => new object());
+ new ValueMapping(null, null, str => new object());
}
- [TestMethod, ExpectedException(typeof(ArgumentNullException))]
+ [TestCase, ExpectedException(typeof(ArgumentNullException))]
public void CtorNullToObject() {
- new ValueMapping(obj => obj.ToString(), null);
+ new ValueMapping(obj => obj.ToString(), null, null);
}
}
}