diff options
Diffstat (limited to 'src/DotNetOpenAuth.Test/OAuth')
9 files changed, 76 insertions, 79 deletions
diff --git a/src/DotNetOpenAuth.Test/OAuth/AppendixScenarios.cs b/src/DotNetOpenAuth.Test/OAuth/AppendixScenarios.cs index c009a83..5584a7b 100644 --- a/src/DotNetOpenAuth.Test/OAuth/AppendixScenarios.cs +++ b/src/DotNetOpenAuth.Test/OAuth/AppendixScenarios.cs @@ -12,11 +12,11 @@ namespace DotNetOpenAuth.Test.OAuth { using DotNetOpenAuth.OAuth; using DotNetOpenAuth.OAuth.ChannelElements; using DotNetOpenAuth.Test.Mocks; - using Microsoft.VisualStudio.TestTools.UnitTesting; + using NUnit.Framework; - [TestClass] + [TestFixture] public class AppendixScenarios : TestBase { - [TestMethod] + [TestCase] public void SpecAppendixAExample() { ServiceProviderDescription serviceDescription = new ServiceProviderDescription() { RequestTokenEndpoint = new MessageReceivingEndpoint("https://photos.example.net/request_token", HttpDeliveryMethods.PostRequest), diff --git a/src/DotNetOpenAuth.Test/OAuth/ChannelElements/HmacSha1SigningBindingElementTests.cs b/src/DotNetOpenAuth.Test/OAuth/ChannelElements/HmacSha1SigningBindingElementTests.cs index 6477510..e1ff959 100644 --- a/src/DotNetOpenAuth.Test/OAuth/ChannelElements/HmacSha1SigningBindingElementTests.cs +++ b/src/DotNetOpenAuth.Test/OAuth/ChannelElements/HmacSha1SigningBindingElementTests.cs @@ -8,17 +8,17 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements { using DotNetOpenAuth.OAuth.ChannelElements; using DotNetOpenAuth.OAuth.Messages; using DotNetOpenAuth.Test.Mocks; - using Microsoft.VisualStudio.TestTools.UnitTesting; + using NUnit.Framework; - [TestClass] + [TestFixture] public class HmacSha1SigningBindingElementTests : MessagingTestBase { - [TestMethod] + [TestCase] public void SignatureTest() { UnauthorizedTokenRequest message = SigningBindingElementBaseTests.CreateTestRequestTokenMessage(this.MessageDescriptions, null); - HmacSha1SigningBindingElement_Accessor hmac = new HmacSha1SigningBindingElement_Accessor(); + var hmac = new HmacSha1SigningBindingElement(); hmac.Channel = new TestChannel(this.MessageDescriptions); - Assert.AreEqual("kR0LhH8UqylaLfR/esXVVlP4sQI=", hmac.GetSignature(message)); + Assert.AreEqual("kR0LhH8UqylaLfR/esXVVlP4sQI=", hmac.GetSignatureTestHook(message)); } } } diff --git a/src/DotNetOpenAuth.Test/OAuth/ChannelElements/OAuthChannelTests.cs b/src/DotNetOpenAuth.Test/OAuth/ChannelElements/OAuthChannelTests.cs index 07a761d..dd6738f 100644 --- a/src/DotNetOpenAuth.Test/OAuth/ChannelElements/OAuthChannelTests.cs +++ b/src/DotNetOpenAuth.Test/OAuth/ChannelElements/OAuthChannelTests.cs @@ -19,17 +19,16 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements { using DotNetOpenAuth.Messaging.Reflection; using DotNetOpenAuth.OAuth.ChannelElements; using DotNetOpenAuth.Test.Mocks; - using Microsoft.VisualStudio.TestTools.UnitTesting; + using NUnit.Framework; - [TestClass] + [TestFixture] public class OAuthChannelTests : TestBase { private OAuthChannel channel; - private OAuthChannel_Accessor accessor; private TestWebRequestHandler webRequestHandler; private SigningBindingElementBase signingElement; private INonceStore nonceStore; - [TestInitialize] + [SetUp] public override void SetUp() { base.SetUp(); @@ -37,36 +36,35 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements { this.signingElement = new RsaSha1SigningBindingElement(new InMemoryTokenManager()); this.nonceStore = new NonceMemoryStore(StandardExpirationBindingElement.MaximumMessageAge); this.channel = new OAuthChannel(this.signingElement, this.nonceStore, new InMemoryTokenManager(), new TestMessageFactory()); - this.accessor = OAuthChannel_Accessor.AttachShadow(this.channel); this.channel.WebRequestHandler = this.webRequestHandler; } - [TestMethod, ExpectedException(typeof(ArgumentNullException))] + [TestCase, ExpectedException(typeof(ArgumentNullException))] public void CtorNullSigner() { new OAuthChannel(null, this.nonceStore, new InMemoryTokenManager(), new TestMessageFactory()); } - [TestMethod, ExpectedException(typeof(ArgumentNullException))] + [TestCase, ExpectedException(typeof(ArgumentNullException))] public void CtorNullStore() { new OAuthChannel(new RsaSha1SigningBindingElement(new InMemoryTokenManager()), null, new InMemoryTokenManager(), new TestMessageFactory()); } - [TestMethod, ExpectedException(typeof(ArgumentNullException))] + [TestCase, ExpectedException(typeof(ArgumentNullException))] public void CtorNullTokenManager() { new OAuthChannel(new RsaSha1SigningBindingElement(new InMemoryTokenManager()), this.nonceStore, null, new TestMessageFactory()); } - [TestMethod] + [TestCase] public void CtorSimpleConsumer() { new OAuthChannel(new RsaSha1SigningBindingElement(new InMemoryTokenManager()), this.nonceStore, (IConsumerTokenManager)new InMemoryTokenManager()); } - [TestMethod] + [TestCase] public void CtorSimpleServiceProvider() { new OAuthChannel(new RsaSha1SigningBindingElement(new InMemoryTokenManager()), this.nonceStore, (IServiceProviderTokenManager)new InMemoryTokenManager()); } - [TestMethod] + [TestCase] public void ReadFromRequestAuthorization() { this.ParameterizedReceiveTest(HttpDeliveryMethods.AuthorizationHeaderRequest); } @@ -75,7 +73,7 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements { /// Verifies that the OAuth ReadFromRequest method gathers parameters /// from the Authorization header, the query string and the entity form data. /// </summary> - [TestMethod] + [TestCase] public void ReadFromRequestAuthorizationScattered() { // Start by creating a standard POST HTTP request. var fields = new Dictionary<string, string> { @@ -99,24 +97,24 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements { IDirectedProtocolMessage requestMessage = this.channel.ReadFromRequest(requestInfo); Assert.IsNotNull(requestMessage); - Assert.IsInstanceOfType(requestMessage, typeof(TestMessage)); + Assert.IsInstanceOf<TestMessage>(requestMessage); TestMessage testMessage = (TestMessage)requestMessage; Assert.AreEqual(15, testMessage.Age); Assert.AreEqual("Andrew", testMessage.Name); Assert.AreEqual("http://hostb/pathB", testMessage.Location.AbsoluteUri); } - [TestMethod] + [TestCase] public void ReadFromRequestForm() { this.ParameterizedReceiveTest(HttpDeliveryMethods.PostRequest); } - [TestMethod] + [TestCase] public void ReadFromRequestQueryString() { this.ParameterizedReceiveTest(HttpDeliveryMethods.GetRequest); } - [TestMethod] + [TestCase] public void SendDirectMessageResponse() { IProtocolMessage message = new TestDirectedMessage { Age = 15, @@ -135,7 +133,7 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements { Assert.AreEqual("http://hostb/pathB", body["Location"]); } - [TestMethod] + [TestCase] public void ReadFromResponse() { var fields = new Dictionary<string, string> { { "age", "15" }, @@ -149,26 +147,25 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements { writer.Write(MessagingUtilities.CreateQueryString(fields)); writer.Flush(); ms.Seek(0, SeekOrigin.Begin); - Channel_Accessor channelAccessor = Channel_Accessor.AttachShadow(this.channel); - IDictionary<string, string> deserializedFields = channelAccessor.ReadFromResponseCore(new CachedDirectWebResponse { CachedResponseStream = ms }); + IDictionary<string, string> deserializedFields = this.channel.ReadFromResponseCoreTestHook(new CachedDirectWebResponse { CachedResponseStream = ms }); Assert.AreEqual(fields.Count, deserializedFields.Count); foreach (string key in fields.Keys) { Assert.AreEqual(fields[key], deserializedFields[key]); } } - [TestMethod, ExpectedException(typeof(ArgumentNullException))] + [TestCase, ExpectedException(typeof(ArgumentNullException))] public void RequestNull() { this.channel.Request(null); } - [TestMethod, ExpectedException(typeof(ArgumentException))] + [TestCase, ExpectedException(typeof(ArgumentException))] public void RequestNullRecipient() { IDirectedProtocolMessage message = new TestDirectedMessage(MessageTransport.Direct); this.channel.Request(message); } - [TestMethod, ExpectedException(typeof(NotSupportedException))] + [TestCase, ExpectedException(typeof(NotSupportedException))] public void RequestBadPreferredScheme() { TestDirectedMessage message = new TestDirectedMessage(MessageTransport.Direct); message.Recipient = new Uri("http://localtest"); @@ -176,7 +173,7 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements { this.channel.Request(message); } - [TestMethod] + [TestCase] public void RequestUsingAuthorizationHeader() { this.ParameterizedRequestTest(HttpDeliveryMethods.AuthorizationHeaderRequest); } @@ -184,7 +181,7 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements { /// <summary> /// Verifies that message parts can be distributed to the query, form, and Authorization header. /// </summary> - [TestMethod] + [TestCase] public void RequestUsingAuthorizationHeaderScattered() { TestDirectedMessage request = new TestDirectedMessage(MessageTransport.Direct) { Age = 15, @@ -217,17 +214,17 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements { Assert.AreEqual("appearinform=formish", this.webRequestHandler.RequestEntityAsString); } - [TestMethod] + [TestCase] public void RequestUsingGet() { this.ParameterizedRequestTest(HttpDeliveryMethods.GetRequest); } - [TestMethod] + [TestCase] public void RequestUsingPost() { this.ParameterizedRequestTest(HttpDeliveryMethods.PostRequest); } - [TestMethod] + [TestCase] public void RequestUsingHead() { this.ParameterizedRequestTest(HttpDeliveryMethods.HeadRequest); } @@ -235,16 +232,16 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements { /// <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); } @@ -349,7 +346,7 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements { IProtocolMessage response = this.channel.Request(request); Assert.IsNotNull(response); - Assert.IsInstanceOfType(response, typeof(TestMessage)); + Assert.IsInstanceOf<TestMessage>(response); TestMessage responseMessage = (TestMessage)response; Assert.AreEqual(request.Age, responseMessage.Age); Assert.AreEqual(request.Name, responseMessage.Name); @@ -366,7 +363,7 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements { }; IProtocolMessage requestMessage = this.channel.ReadFromRequest(CreateHttpRequestInfo(scheme, fields)); Assert.IsNotNull(requestMessage); - Assert.IsInstanceOfType(requestMessage, typeof(TestMessage)); + Assert.IsInstanceOf<TestMessage>(requestMessage); TestMessage testMessage = (TestMessage)requestMessage; Assert.AreEqual(15, testMessage.Age); Assert.AreEqual("Andrew", testMessage.Name); diff --git a/src/DotNetOpenAuth.Test/OAuth/ChannelElements/PlaintextSigningBindingElementTest.cs b/src/DotNetOpenAuth.Test/OAuth/ChannelElements/PlaintextSigningBindingElementTest.cs index b69e11c..c497495 100644 --- a/src/DotNetOpenAuth.Test/OAuth/ChannelElements/PlaintextSigningBindingElementTest.cs +++ b/src/DotNetOpenAuth.Test/OAuth/ChannelElements/PlaintextSigningBindingElementTest.cs @@ -10,11 +10,11 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements { using DotNetOpenAuth.OAuth.ChannelElements; using DotNetOpenAuth.OAuth.Messages; using DotNetOpenAuth.Test.Mocks; - using Microsoft.VisualStudio.TestTools.UnitTesting; + using NUnit.Framework; - [TestClass] + [TestFixture] public class PlaintextSigningBindingElementTest { - [TestMethod] + [TestCase] public void HttpsSignatureGeneration() { SigningBindingElementBase target = new PlaintextSigningBindingElement(); target.Channel = new TestChannel(); @@ -27,7 +27,7 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements { Assert.AreEqual("cs&ts", message.Signature); } - [TestMethod] + [TestCase] public void HttpsSignatureVerification() { MessageReceivingEndpoint endpoint = new MessageReceivingEndpoint("https://localtest", HttpDeliveryMethods.GetRequest); ITamperProtectionChannelBindingElement target = new PlaintextSigningBindingElement(); @@ -40,7 +40,7 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements { Assert.IsNotNull(target.ProcessIncomingMessage(message)); } - [TestMethod] + [TestCase] public void HttpsSignatureVerificationNotApplicable() { SigningBindingElementBase target = new PlaintextSigningBindingElement(); target.Channel = new TestChannel(); @@ -53,7 +53,7 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements { Assert.AreEqual(MessageProtections.None, target.ProcessIncomingMessage(message), "PLAINTEXT binding element should opt-out where it doesn't understand."); } - [TestMethod] + [TestCase] public void HttpSignatureGeneration() { SigningBindingElementBase target = new PlaintextSigningBindingElement(); target.Channel = new TestChannel(); @@ -68,7 +68,7 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements { Assert.IsNull(message.Signature); } - [TestMethod] + [TestCase] public void HttpSignatureVerification() { SigningBindingElementBase target = new PlaintextSigningBindingElement(); target.Channel = new TestChannel(); diff --git a/src/DotNetOpenAuth.Test/OAuth/ChannelElements/SigningBindingElementBaseTests.cs b/src/DotNetOpenAuth.Test/OAuth/ChannelElements/SigningBindingElementBaseTests.cs index 49549f5..2ef7e9a 100644 --- a/src/DotNetOpenAuth.Test/OAuth/ChannelElements/SigningBindingElementBaseTests.cs +++ b/src/DotNetOpenAuth.Test/OAuth/ChannelElements/SigningBindingElementBaseTests.cs @@ -10,11 +10,11 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements { using DotNetOpenAuth.OAuth; using DotNetOpenAuth.OAuth.ChannelElements; using DotNetOpenAuth.OAuth.Messages; - using Microsoft.VisualStudio.TestTools.UnitTesting; + using NUnit.Framework; - [TestClass] + [TestFixture] public class SigningBindingElementBaseTests : MessagingTestBase { - [TestMethod] + [TestCase] public void BaseSignatureStringTest() { // Tests a message sent by HTTP GET, with no query string included in the endpoint. UnauthorizedTokenRequest message = CreateTestRequestTokenMessage( @@ -22,7 +22,7 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements { new MessageReceivingEndpoint("https://www.google.com/accounts/OAuthGetRequestToken", HttpDeliveryMethods.AuthorizationHeaderRequest | HttpDeliveryMethods.GetRequest)); Assert.AreEqual( "GET&https%3A%2F%2Fwww.google.com%2Faccounts%2FOAuthGetRequestToken&oauth_consumer_key%3Dnerdbank.org%26oauth_nonce%3Dfe4045a3f0efdd1e019fa8f8ae3f5c38%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1222665749%26oauth_version%3D1.0%26scope%3Dhttp%253A%252F%252Fwww.google.com%252Fm8%252Ffeeds%252F", - SigningBindingElementBase_Accessor.ConstructSignatureBaseString(message, MessageDictionary_Accessor.AttachShadow(this.MessageDescriptions.GetAccessor(message)))); + SigningBindingElementBase.ConstructSignatureBaseString(message, this.MessageDescriptions.GetAccessor(message))); // Test HTTP GET with an attached query string. We're elevating the scope parameter to the query string // and removing it from the extradata dictionary. This should NOT affect the base signature string. @@ -32,7 +32,7 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements { message.ExtraData.Remove("scope"); // remove it from ExtraData since we put it in the URL Assert.AreEqual( "GET&https%3A%2F%2Fwww.google.com%2Faccounts%2FOAuthGetRequestToken&oauth_consumer_key%3Dnerdbank.org%26oauth_nonce%3Dfe4045a3f0efdd1e019fa8f8ae3f5c38%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1222665749%26oauth_version%3D1.0%26scope%3Dhttp%253A%252F%252Fwww.google.com%252Fm8%252Ffeeds%252F", - SigningBindingElementBase_Accessor.ConstructSignatureBaseString(message, MessageDictionary_Accessor.AttachShadow(this.MessageDescriptions.GetAccessor(message)))); + SigningBindingElementBase.ConstructSignatureBaseString(message, this.MessageDescriptions.GetAccessor(message))); // Test HTTP POST, with query string as well message = CreateTestRequestTokenMessage( @@ -41,7 +41,7 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements { message.ExtraData.Remove("scope"); // remove it from ExtraData since we put it in the URL Assert.AreEqual( "GET&https%3A%2F%2Fwww.google.com%2Faccounts%2FOAuthGetRequestToken&oauth_consumer_key%3Dnerdbank.org%26oauth_nonce%3Dfe4045a3f0efdd1e019fa8f8ae3f5c38%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1222665749%26oauth_version%3D1.0%26scope%3Dhttp%253A%252F%252Fwww.google.com%252Fm8%252Ffeeds%252F", - SigningBindingElementBase_Accessor.ConstructSignatureBaseString(message, MessageDictionary_Accessor.AttachShadow(this.MessageDescriptions.GetAccessor(message)))); + SigningBindingElementBase.ConstructSignatureBaseString(message, this.MessageDescriptions.GetAccessor(message))); // Test HTTP POST, with query string, but not using the Authorization header message = CreateTestRequestTokenMessage( @@ -50,7 +50,7 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements { message.ExtraData.Remove("scope"); // remove it from ExtraData since we put it in the URL Assert.AreEqual( "GET&https%3A%2F%2Fwww.google.com%2Faccounts%2FOAuthGetRequestToken&oauth_consumer_key%3Dnerdbank.org%26oauth_nonce%3Dfe4045a3f0efdd1e019fa8f8ae3f5c38%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1222665749%26oauth_version%3D1.0%26scope%3Dhttp%253A%252F%252Fwww.google.com%252Fm8%252Ffeeds%252F", - SigningBindingElementBase_Accessor.ConstructSignatureBaseString(message, MessageDictionary_Accessor.AttachShadow(this.MessageDescriptions.GetAccessor(message)))); + SigningBindingElementBase.ConstructSignatureBaseString(message, this.MessageDescriptions.GetAccessor(message))); // This is a simulation of receiving the message, where the query string is still in the URL, // but has been read into ExtraData, so parameters in the query string appear twice. @@ -59,7 +59,7 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements { new MessageReceivingEndpoint("https://www.google.com/accounts/OAuthGetRequestToken?scope=http://www.google.com/m8/feeds/", HttpDeliveryMethods.AuthorizationHeaderRequest | HttpDeliveryMethods.PostRequest)); Assert.AreEqual( "GET&https%3A%2F%2Fwww.google.com%2Faccounts%2FOAuthGetRequestToken&oauth_consumer_key%3Dnerdbank.org%26oauth_nonce%3Dfe4045a3f0efdd1e019fa8f8ae3f5c38%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1222665749%26oauth_version%3D1.0%26scope%3Dhttp%253A%252F%252Fwww.google.com%252Fm8%252Ffeeds%252F", - SigningBindingElementBase_Accessor.ConstructSignatureBaseString(message, MessageDictionary_Accessor.AttachShadow(this.MessageDescriptions.GetAccessor(message)))); + SigningBindingElementBase.ConstructSignatureBaseString(message, this.MessageDescriptions.GetAccessor(message))); } internal static UnauthorizedTokenRequest CreateTestRequestTokenMessage(MessageDescriptionCollection messageDescriptions, MessageReceivingEndpoint endpoint) { diff --git a/src/DotNetOpenAuth.Test/OAuth/ChannelElements/UriOrOobEncodingTests.cs b/src/DotNetOpenAuth.Test/OAuth/ChannelElements/UriOrOobEncodingTests.cs index 40fc93e..715669a 100644 --- a/src/DotNetOpenAuth.Test/OAuth/ChannelElements/UriOrOobEncodingTests.cs +++ b/src/DotNetOpenAuth.Test/OAuth/ChannelElements/UriOrOobEncodingTests.cs @@ -10,13 +10,13 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements { using System.Linq; using System.Text; using DotNetOpenAuth.OAuth.ChannelElements; - using Microsoft.VisualStudio.TestTools.UnitTesting; + using NUnit.Framework; - [TestClass] + [TestFixture] public class UriOrOobEncodingTests : TestBase { private UriOrOobEncoding encoding; - [TestInitialize] + [SetUp] public void Setup() { this.encoding = new UriOrOobEncoding(); } @@ -24,7 +24,7 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements { /// <summary> /// Verifies null value encoding /// </summary> - [TestMethod] + [TestCase] public void NullValueEncoding() { Assert.AreEqual("oob", this.encoding.EncodedNullValue); } @@ -32,7 +32,7 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements { /// <summary> /// Verifies decoding "oob" results in a null uri. /// </summary> - [TestMethod] + [TestCase] public void DecodeOobToNullUri() { Assert.IsNull(this.encoding.Decode("oob")); } @@ -40,7 +40,7 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements { /// <summary> /// Verifies that decoding an empty string generates an exception. /// </summary> - [TestMethod, ExpectedException(typeof(UriFormatException))] + [TestCase, ExpectedException(typeof(UriFormatException))] public void DecodeEmptyStringFails() { this.encoding.Decode(string.Empty); } @@ -48,7 +48,7 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements { /// <summary> /// Verifies proper decoding/encoding of a Uri /// </summary> - [TestMethod] + [TestCase] public void UriEncodeDecode() { Uri original = new Uri("http://somehost/p?q=a#frag"); string encodedValue = this.encoding.Encode(original); @@ -60,7 +60,7 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements { /// <summary> /// Verifies failure to decode a relative Uri /// </summary> - [TestMethod, ExpectedException(typeof(UriFormatException))] + [TestCase, ExpectedException(typeof(UriFormatException))] public void RelativeUriDecodeFails() { this.encoding.Decode("../a/b"); } diff --git a/src/DotNetOpenAuth.Test/OAuth/ProtocolTests.cs b/src/DotNetOpenAuth.Test/OAuth/ProtocolTests.cs index e60a9e2..6fac69e 100644 --- a/src/DotNetOpenAuth.Test/OAuth/ProtocolTests.cs +++ b/src/DotNetOpenAuth.Test/OAuth/ProtocolTests.cs @@ -6,27 +6,27 @@ namespace DotNetOpenAuth.Test.OAuth { using DotNetOpenAuth.OAuth; - using Microsoft.VisualStudio.TestTools.UnitTesting; + using NUnit.Framework; - [TestClass] + [TestFixture] public class ProtocolTests { - [TestMethod] + [TestCase] public void Default() { Assert.AreSame(Protocol.V10a, Protocol.Default); } - [TestMethod] + [TestCase] public void DataContractNamespace() { Assert.AreEqual("http://oauth.net/core/1.0/", Protocol.V10.DataContractNamespace); Assert.AreEqual("http://oauth.net/core/1.0/", Protocol.DataContractNamespaceV10); } - [TestMethod] + [TestCase] public void AuthorizationHeaderScheme() { Assert.AreEqual("OAuth", Protocol.AuthorizationHeaderScheme); } - [TestMethod] + [TestCase] public void ParameterPrefix() { Assert.AreEqual("oauth_", Protocol.ParameterPrefix); } diff --git a/src/DotNetOpenAuth.Test/OAuth/ServiceProviderDescriptionTests.cs b/src/DotNetOpenAuth.Test/OAuth/ServiceProviderDescriptionTests.cs index 3430103..1aa401d 100644 --- a/src/DotNetOpenAuth.Test/OAuth/ServiceProviderDescriptionTests.cs +++ b/src/DotNetOpenAuth.Test/OAuth/ServiceProviderDescriptionTests.cs @@ -8,17 +8,17 @@ namespace DotNetOpenAuth.Test.OAuth { using System; using DotNetOpenAuth.Messaging; using DotNetOpenAuth.OAuth; - using Microsoft.VisualStudio.TestTools.UnitTesting; + using NUnit.Framework; /// <summary> /// Tests for the <see cref="ServiceProviderEndpoints"/> class. /// </summary> - [TestClass] + [TestFixture] public class ServiceProviderDescriptionTests : TestBase { /// <summary> /// A test for UserAuthorizationUri /// </summary> - [TestMethod] + [TestCase] public void UserAuthorizationUriTest() { ServiceProviderDescription target = new ServiceProviderDescription(); MessageReceivingEndpoint expected = new MessageReceivingEndpoint("http://localhost/authorization", HttpDeliveryMethods.GetRequest); @@ -34,7 +34,7 @@ namespace DotNetOpenAuth.Test.OAuth { /// <summary> /// A test for RequestTokenUri /// </summary> - [TestMethod] + [TestCase] public void RequestTokenUriTest() { var target = new ServiceProviderDescription(); MessageReceivingEndpoint expected = new MessageReceivingEndpoint("http://localhost/requesttoken", HttpDeliveryMethods.GetRequest); @@ -51,7 +51,7 @@ namespace DotNetOpenAuth.Test.OAuth { /// Verifies that oauth parameters are not allowed in <see cref="ServiceProvider.RequestTokenUri"/>, /// per section OAuth 1.0 section 4.1. /// </summary> - [TestMethod, ExpectedException(typeof(ArgumentException))] + [TestCase, ExpectedException(typeof(ArgumentException))] public void RequestTokenUriWithOAuthParametersTest() { var target = new ServiceProviderDescription(); target.RequestTokenEndpoint = new MessageReceivingEndpoint("http://localhost/requesttoken?oauth_token=something", HttpDeliveryMethods.GetRequest); @@ -60,7 +60,7 @@ namespace DotNetOpenAuth.Test.OAuth { /// <summary> /// A test for AccessTokenUri /// </summary> - [TestMethod] + [TestCase] public void AccessTokenUriTest() { var target = new ServiceProviderDescription(); MessageReceivingEndpoint expected = new MessageReceivingEndpoint("http://localhost/accesstoken", HttpDeliveryMethods.GetRequest); diff --git a/src/DotNetOpenAuth.Test/OAuth/ServiceProviderTests.cs b/src/DotNetOpenAuth.Test/OAuth/ServiceProviderTests.cs index 2a443ce..ceb9a60 100644 --- a/src/DotNetOpenAuth.Test/OAuth/ServiceProviderTests.cs +++ b/src/DotNetOpenAuth.Test/OAuth/ServiceProviderTests.cs @@ -11,14 +11,14 @@ namespace DotNetOpenAuth.Test.OAuth { using System.Text; using DotNetOpenAuth.Messaging; using DotNetOpenAuth.OAuth; - using Microsoft.VisualStudio.TestTools.UnitTesting; + using NUnit.Framework; - [TestClass] + [TestFixture] public class ServiceProviderTests : TestBase { /// <summary> /// Verifies the CreateVerificationCode method. /// </summary> - [TestMethod] + [TestCase] public void CreateVerificationCode() { this.TestCode(VerificationCodeFormat.Numeric, 3, MessagingUtilities.Digits); this.TestCode(VerificationCodeFormat.AlphaLower, 5, MessagingUtilities.LowercaseLetters); @@ -28,7 +28,7 @@ namespace DotNetOpenAuth.Test.OAuth { private void TestCode(VerificationCodeFormat format, int length, string allowableCharacters) { string code = ServiceProvider.CreateVerificationCode(format, length); - TestContext.WriteLine("{0} of length {2}: {1}", format, code, length); + TestUtilities.TestLogger.InfoFormat("{0} of length {2}: {1}", format, code, length); Assert.AreEqual(length, code.Length); foreach (char ch in code) { Assert.IsTrue(allowableCharacters.Contains(ch)); |