diff options
Diffstat (limited to 'src/DotNetOpenAuth.Test/OpenId/ChannelElements/OpenIdChannelTests.cs')
-rw-r--r-- | src/DotNetOpenAuth.Test/OpenId/ChannelElements/OpenIdChannelTests.cs | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/src/DotNetOpenAuth.Test/OpenId/ChannelElements/OpenIdChannelTests.cs b/src/DotNetOpenAuth.Test/OpenId/ChannelElements/OpenIdChannelTests.cs index 385cd19..eaaef34 100644 --- a/src/DotNetOpenAuth.Test/OpenId/ChannelElements/OpenIdChannelTests.cs +++ b/src/DotNetOpenAuth.Test/OpenId/ChannelElements/OpenIdChannelTests.cs @@ -18,24 +18,22 @@ namespace DotNetOpenAuth.Test.OpenId.ChannelElements { using DotNetOpenAuth.OpenId.ChannelElements; using DotNetOpenAuth.OpenId.RelyingParty; using DotNetOpenAuth.Test.Mocks; - using Microsoft.VisualStudio.TestTools.UnitTesting; + using NUnit.Framework; - [TestClass] + [TestFixture] public class OpenIdChannelTests : TestBase { private static readonly TimeSpan maximumMessageAge = TimeSpan.FromHours(3); // good for tests, too long for production private OpenIdChannel channel; - private OpenIdChannel_Accessor accessor; private Mocks.TestWebRequestHandler webHandler; - [TestInitialize] + [SetUp] public void Setup() { this.webHandler = new Mocks.TestWebRequestHandler(); this.channel = new OpenIdChannel(new AssociationMemoryStore<Uri>(), new NonceMemoryStore(maximumMessageAge), new RelyingPartySecuritySettings()); - this.accessor = OpenIdChannel_Accessor.AttachShadow(this.channel); this.channel.WebRequestHandler = this.webHandler; } - [TestMethod] + [TestCase] public void Ctor() { // Verify that the channel stack includes the expected types. // While other binding elements may be substituted for these, we'd then have @@ -53,15 +51,15 @@ namespace DotNetOpenAuth.Test.OpenId.ChannelElements { /// <summary> /// Verifies that the channel sends direct message requests as HTTP POST requests. /// </summary> - [TestMethod] + [TestCase] public void DirectRequestsUsePost() { IDirectedProtocolMessage requestMessage = new Mocks.TestDirectedMessage(MessageTransport.Direct) { Recipient = new Uri("http://host"), Name = "Andrew", }; - HttpWebRequest httpRequest = this.accessor.CreateHttpRequest(requestMessage); + HttpWebRequest httpRequest = this.channel.CreateHttpRequestTestHook(requestMessage); Assert.AreEqual("POST", httpRequest.Method); - StringAssert.Contains(this.webHandler.RequestEntityAsString, "Name=Andrew"); + StringAssert.Contains("Name=Andrew", this.webHandler.RequestEntityAsString); } /// <summary> @@ -73,14 +71,14 @@ namespace DotNetOpenAuth.Test.OpenId.ChannelElements { /// class is verified elsewhere. We're only checking that the KVF class is being used by the /// <see cref="OpenIdChannel.SendDirectMessageResponse"/> method. /// </remarks> - [TestMethod] + [TestCase] public void DirectResponsesSentUsingKeyValueForm() { IProtocolMessage message = MessagingTestBase.GetStandardTestMessage(MessagingTestBase.FieldFill.AllRequired); MessageDictionary messageFields = this.MessageDescriptions.GetAccessor(message); byte[] expectedBytes = KeyValueFormEncoding.GetBytes(messageFields); - string expectedContentType = OpenIdChannel_Accessor.KeyValueFormContentType; + string expectedContentType = OpenIdChannel.KeyValueFormContentType; - OutgoingWebResponse directResponse = this.accessor.PrepareDirectResponse(message); + OutgoingWebResponse directResponse = this.channel.PrepareDirectResponseTestHook(message); Assert.AreEqual(expectedContentType, directResponse.Headers[HttpResponseHeader.ContentType]); byte[] actualBytes = new byte[directResponse.ResponseStream.Length]; directResponse.ResponseStream.Read(actualBytes, 0, actualBytes.Length); @@ -90,7 +88,7 @@ namespace DotNetOpenAuth.Test.OpenId.ChannelElements { /// <summary> /// Verifies that direct message responses are read in using the Key Value Form decoder. /// </summary> - [TestMethod] + [TestCase] public void DirectResponsesReceivedAsKeyValueForm() { var fields = new Dictionary<string, string> { { "var1", "value1" }, @@ -99,22 +97,22 @@ namespace DotNetOpenAuth.Test.OpenId.ChannelElements { var response = new CachedDirectWebResponse { CachedResponseStream = new MemoryStream(KeyValueFormEncoding.GetBytes(fields)), }; - Assert.IsTrue(MessagingUtilities.AreEquivalent(fields, this.accessor.ReadFromResponseCore(response))); + Assert.IsTrue(MessagingUtilities.AreEquivalent(fields, this.channel.ReadFromResponseCoreTestHook(response))); } /// <summary> /// Verifies that messages asking for special HTTP status codes get them. /// </summary> - [TestMethod] + [TestCase] public void SendDirectMessageResponseHonorsHttpStatusCodes() { IProtocolMessage message = MessagingTestBase.GetStandardTestMessage(MessagingTestBase.FieldFill.AllRequired); - OutgoingWebResponse directResponse = this.accessor.PrepareDirectResponse(message); + OutgoingWebResponse directResponse = this.channel.PrepareDirectResponseTestHook(message); Assert.AreEqual(HttpStatusCode.OK, directResponse.Status); var httpMessage = new TestDirectResponseMessageWithHttpStatus(); MessagingTestBase.GetStandardTestMessage(MessagingTestBase.FieldFill.AllRequired, httpMessage); httpMessage.HttpStatusCode = HttpStatusCode.NotAcceptable; - directResponse = this.accessor.PrepareDirectResponse(httpMessage); + directResponse = this.channel.PrepareDirectResponseTestHook(httpMessage); Assert.AreEqual(HttpStatusCode.NotAcceptable, directResponse.Status); } } |