summaryrefslogtreecommitdiffstats
path: root/src/DotNetOAuth.Test/ServiceProviderTest.cs
blob: d4bced7396d69a34a7c06ef2f9e84f6a68c715bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//-----------------------------------------------------------------------
// <copyright file="ServiceProviderTest.cs" company="Andrew Arnott">
//     Copyright (c) Andrew Arnott. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace DotNetOAuth.Test {
	using System;
	using Microsoft.VisualStudio.TestTools.UnitTesting;

	/// <summary>
	/// Tests for the <see cref="ServiceProvider"/> class.
	/// </summary>
	[TestClass]
	public class ServiceProviderTest : TestBase {
		/// <summary>
		/// A test for UserAuthorizationUri
		/// </summary>
		[TestMethod]
		public void UserAuthorizationUriTest() {
			ServiceProvider target = new ServiceProvider();
			Uri expected = new Uri("http://localhost/authorization");
			Uri actual;
			target.UserAuthorizationUri = expected;
			actual = target.UserAuthorizationUri;
			Assert.AreEqual(expected, actual);
		}

		/// <summary>
		/// A test for RequestTokenUri
		/// </summary>
		[TestMethod()]
		public void RequestTokenUriTest() {
			ServiceProvider target = new ServiceProvider();
			Uri expected = new Uri("http://localhost/requesttoken");
			Uri actual;
			target.RequestTokenUri = expected;
			actual = target.RequestTokenUri;
			Assert.AreEqual(expected, actual);
		}

		/// <summary>
		/// 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))]
		public void RequestTokenUriWithOAuthParametersTest() {
			ServiceProvider target = new ServiceProvider();
			target.RequestTokenUri = new Uri("http://localhost/requesttoken?oauth_token=something");
		}

		/// <summary>
		/// A test for AccessTokenUri
		/// </summary>
		[TestMethod()]
		public void AccessTokenUriTest() {
			ServiceProvider target = new ServiceProvider();
			Uri expected = new Uri("http://localhost/accesstoken");
			Uri actual;
			target.AccessTokenUri = expected;
			actual = target.AccessTokenUri;
			Assert.AreEqual(expected, actual);
		}
	}
}