OLD | NEW |
(Empty) | |
| 1 /* |
| 2 Copyright 2013 Google Inc |
| 3 |
| 4 Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 you may not use this file except in compliance with the License. |
| 6 You may obtain a copy of the License at |
| 7 |
| 8 http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
| 10 Unless required by applicable law or agreed to in writing, software |
| 11 distributed under the License is distributed on an "AS IS" BASIS, |
| 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 See the License for the specific language governing permissions and |
| 14 limitations under the License. |
| 15 */ |
| 16 |
| 17 using System; |
| 18 using System.Collections.Generic; |
| 19 using System.Linq; |
| 20 using System.Text; |
| 21 |
| 22 using NUnit.Framework; |
| 23 |
| 24 namespace Google.Apis.Auth.OAuth2.Responses |
| 25 { |
| 26 /// <summary> |
| 27 /// Tests for <seealso cref="Google.Apis.Auth.OAuth2.Responses.Authorization
CodeResponseUrl"/>. |
| 28 /// </summary> |
| 29 [TestFixture] |
| 30 public class AuthorizationCodeResponseUrlTests |
| 31 { |
| 32 [Test] |
| 33 public void TestConstructor_Default() |
| 34 { |
| 35 var response = new AuthorizationCodeResponseUrl(); |
| 36 Assert.Null(response.Code); |
| 37 Assert.Null(response.Error); |
| 38 Assert.Null(response.ErrorUri); |
| 39 Assert.Null(response.ErrorDescription); |
| 40 Assert.Null(response.State); |
| 41 } |
| 42 |
| 43 [Test] |
| 44 public void TestConstructor_Dictionary() |
| 45 { |
| 46 var dic = new Dictionary<string, string>(); |
| 47 dic["code"] = "123"; |
| 48 dic["error"] = "ERR"; |
| 49 dic["error_uri"] = "URI"; |
| 50 dic["error_description"] = "DESC"; |
| 51 dic["state"] = "STATE"; |
| 52 |
| 53 // Some other parameter, which is not part of the response. |
| 54 dic["another_one"] = "BLAH BLAH BLAH"; |
| 55 |
| 56 var response = new AuthorizationCodeResponseUrl(dic); |
| 57 SubtestConstructor(response); |
| 58 } |
| 59 |
| 60 [Test] |
| 61 public void TestConstructor_Query() |
| 62 { |
| 63 string query = "code=123&error=ERR&error_uri=URI&error_description=D
ESC&state=STATE&other_ine=2222222222"; |
| 64 var response = new AuthorizationCodeResponseUrl(query); |
| 65 SubtestConstructor(response); |
| 66 } |
| 67 |
| 68 private void SubtestConstructor(AuthorizationCodeResponseUrl response) |
| 69 { |
| 70 Assert.That(response.Code, Is.EqualTo("123")); |
| 71 Assert.That(response.Error, Is.EqualTo("ERR")); |
| 72 Assert.That(response.ErrorUri, Is.EqualTo("URI")); |
| 73 Assert.That(response.ErrorDescription, Is.EqualTo("DESC")); |
| 74 Assert.That(response.State, Is.EqualTo("STATE")); |
| 75 } |
| 76 } |
| 77 } |
OLD | NEW |