summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.Test/Messaging/StandardMessageFactoryTests.cs
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2010-02-21 20:28:03 -0800
committerAndrew Arnott <andrewarnott@gmail.com>2010-02-22 08:39:09 -0800
commit87bf956ee99a9d34e92d32f67e3d655e5594f8fb (patch)
tree8dbdc53c77a5fee567ca2df20b2ad5a812c6477e /src/DotNetOpenAuth.Test/Messaging/StandardMessageFactoryTests.cs
parent4bc457d90453f31f80f3cc841945760c0aa1ad68 (diff)
downloadDotNetOpenAuth-87bf956ee99a9d34e92d32f67e3d655e5594f8fb.zip
DotNetOpenAuth-87bf956ee99a9d34e92d32f67e3d655e5594f8fb.tar.gz
DotNetOpenAuth-87bf956ee99a9d34e92d32f67e3d655e5594f8fb.tar.bz2
StandardMessageFactory now has an initializing virtual method instead of doing a bunch of hard-coded work in the constructor.
Diffstat (limited to 'src/DotNetOpenAuth.Test/Messaging/StandardMessageFactoryTests.cs')
-rw-r--r--src/DotNetOpenAuth.Test/Messaging/StandardMessageFactoryTests.cs34
1 files changed, 21 insertions, 13 deletions
diff --git a/src/DotNetOpenAuth.Test/Messaging/StandardMessageFactoryTests.cs b/src/DotNetOpenAuth.Test/Messaging/StandardMessageFactoryTests.cs
index 2768350..2b0b4e7 100644
--- a/src/DotNetOpenAuth.Test/Messaging/StandardMessageFactoryTests.cs
+++ b/src/DotNetOpenAuth.Test/Messaging/StandardMessageFactoryTests.cs
@@ -19,20 +19,28 @@ namespace DotNetOpenAuth.Test.Messaging {
private static readonly Version V1 = new Version(1, 0);
private static readonly MessageReceivingEndpoint receiver = new MessageReceivingEndpoint("http://receiver", HttpDeliveryMethods.PostRequest);
+ private StandardMessageFactory factory;
+
+ public override void SetUp() {
+ base.SetUp();
+
+ this.factory = new StandardMessageFactory();
+ }
+
/// <summary>
- /// Verifies the constructor throws the appropriate exception on null input.
+ /// Verifies that AddMessageTypes throws the appropriate exception on null input.
/// </summary>
[TestCase, ExpectedException(typeof(ArgumentNullException))]
- public void CtorNull() {
- new StandardMessageFactory(null);
+ public void AddMessageTypesNull() {
+ this.factory.AddMessageTypes(null);
}
/// <summary>
- /// Verifies the constructor throws the appropriate exception on null input.
+ /// Verifies that AddMessageTypes throws the appropriate exception on null input.
/// </summary>
[TestCase, ExpectedException(typeof(ArgumentException))]
- public void CtorNullMessageDescription() {
- new StandardMessageFactory(new MessageDescription[] { null });
+ public void AddMessageTypesNullMessageDescription() {
+ this.factory.AddMessageTypes(new MessageDescription[] { null });
}
/// <summary>
@@ -40,13 +48,13 @@ namespace DotNetOpenAuth.Test.Messaging {
/// </summary>
[TestCase]
public void SingleRequestMessageType() {
- var factory = new StandardMessageFactory(new MessageDescription[] { MessageDescriptions.Get(typeof(RequestMessageMock), V1) });
+ this.factory.AddMessageTypes(new MessageDescription[] { MessageDescriptions.Get(typeof(RequestMessageMock), V1) });
var fields = new Dictionary<string, string> {
{ "random", "bits" },
};
- Assert.IsNull(factory.GetNewRequestMessage(receiver, fields));
+ Assert.IsNull(this.factory.GetNewRequestMessage(receiver, fields));
fields["Age"] = "18";
- Assert.IsInstanceOf(typeof(RequestMessageMock), factory.GetNewRequestMessage(receiver, fields));
+ Assert.IsInstanceOf(typeof(RequestMessageMock), this.factory.GetNewRequestMessage(receiver, fields));
}
/// <summary>
@@ -54,20 +62,20 @@ namespace DotNetOpenAuth.Test.Messaging {
/// </summary>
[TestCase]
public void SingleResponseMessageType() {
- var factory = new StandardMessageFactory(new MessageDescription[] { MessageDescriptions.Get(typeof(DirectResponseMessageMock), V1) });
+ this.factory.AddMessageTypes(new MessageDescription[] { MessageDescriptions.Get(typeof(DirectResponseMessageMock), V1) });
var fields = new Dictionary<string, string> {
{ "random", "bits" },
};
IDirectedProtocolMessage request = new RequestMessageMock(receiver.Location, V1);
- Assert.IsNull(factory.GetNewResponseMessage(request, fields));
+ Assert.IsNull(this.factory.GetNewResponseMessage(request, fields));
fields["Age"] = "18";
- IDirectResponseProtocolMessage response = factory.GetNewResponseMessage(request, fields);
+ IDirectResponseProtocolMessage response = this.factory.GetNewResponseMessage(request, fields);
Assert.IsInstanceOf<DirectResponseMessageMock>(response);
Assert.AreSame(request, response.OriginatingRequest);
// Verify that we can instantiate a response with a derived-type of an expected request message.
request = new TestSignedDirectedMessage();
- response = factory.GetNewResponseMessage(request, fields);
+ response = this.factory.GetNewResponseMessage(request, fields);
Assert.IsInstanceOf<DirectResponseMessageMock>(response);
Assert.AreSame(request, response.OriginatingRequest);
}