summaryrefslogtreecommitdiffstats
path: root/src/DotNetOAuth.Test/Mocks/MockTransformationBindingElement.cs
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2008-09-13 13:42:46 -0700
committerAndrew <andrewarnott@gmail.com>2008-09-13 13:42:46 -0700
commitf665e1e639319918385fcc8397f8c0d5009e3bdd (patch)
tree6219f476ab24bc187eac79b501d7de73c9acd234 /src/DotNetOAuth.Test/Mocks/MockTransformationBindingElement.cs
parent61650a6ec207c94cb92e27227dac75606c3e7e00 (diff)
downloadDotNetOpenAuth-f665e1e639319918385fcc8397f8c0d5009e3bdd.zip
DotNetOpenAuth-f665e1e639319918385fcc8397f8c0d5009e3bdd.tar.gz
DotNetOpenAuth-f665e1e639319918385fcc8397f8c0d5009e3bdd.tar.bz2
Totally refactored signing, expiration and replay detection into extensible channel binding elements.
Diffstat (limited to 'src/DotNetOAuth.Test/Mocks/MockTransformationBindingElement.cs')
-rw-r--r--src/DotNetOAuth.Test/Mocks/MockTransformationBindingElement.cs49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/DotNetOAuth.Test/Mocks/MockTransformationBindingElement.cs b/src/DotNetOAuth.Test/Mocks/MockTransformationBindingElement.cs
new file mode 100644
index 0000000..7a1320b
--- /dev/null
+++ b/src/DotNetOAuth.Test/Mocks/MockTransformationBindingElement.cs
@@ -0,0 +1,49 @@
+//-----------------------------------------------------------------------
+// <copyright file="MockTransformationBindingElement.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOAuth.Test.Mocks {
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Text;
+ using DotNetOAuth.Messaging;
+ using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+ internal class MockTransformationBindingElement : IChannelBindingElement {
+ private string transform;
+
+ internal MockTransformationBindingElement(string transform) {
+ if (transform == null) {
+ throw new ArgumentNullException("transform");
+ }
+
+ this.transform = transform;
+ }
+
+ #region IChannelBindingElement Members
+
+ ChannelProtection IChannelBindingElement.Protection {
+ get { return ChannelProtection.None; }
+ }
+
+ void IChannelBindingElement.PrepareMessageForSending(IProtocolMessage message) {
+ var testMessage = message as TestMessage;
+ if (testMessage != null) {
+ testMessage.Name = this.transform + testMessage.Name;
+ }
+ }
+
+ void IChannelBindingElement.PrepareMessageForReceiving(IProtocolMessage message) {
+ var testMessage = message as TestMessage;
+ if (testMessage != null) {
+ StringAssert.StartsWith(testMessage.Name, this.transform);
+ testMessage.Name = testMessage.Name.Substring(this.transform.Length);
+ }
+ }
+
+ #endregion
+ }
+}