Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1555)

Delta Between Two Patch Sets: Src/GoogleApis.Auth.Tests/OAuth2/Responses/TokenResponseTests.cs

Issue 13972043: Issue 351: Reimplement OAuth2 (Step 3 - Tests, Flows and Credential) (Closed) Base URL: https://google-api-dotnet-client.googlecode.com/hg/
Left Patch Set: minor Created 10 years, 6 months ago
Right Patch Set: minor Created 10 years, 5 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
1 /* 1 /*
2 Copyright 2013 Google Inc 2 Copyright 2013 Google Inc
3 3
4 Licensed under the Apache License, Version 2.0 (the "License"); 4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with 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 6 You may obtain a copy of the License at
7 7
8 http://www.apache.org/licenses/LICENSE-2.0 8 http://www.apache.org/licenses/LICENSE-2.0
9 9
10 Unless required by applicable law or agreed to in writing, software 10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS, 11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and 13 See the License for the specific language governing permissions and
14 limitations under the License. 14 limitations under the License.
15 */ 15 */
16 16
17 using System; 17 using System;
18 using System.Collections.Generic; 18 using System.Collections.Generic;
19 using System.Linq; 19 using System.Linq;
20 using System.Text; 20 using System.Text;
21 21
22 using NUnit.Framework; 22 using NUnit.Framework;
23 using Newtonsoft.Json; 23 using Newtonsoft.Json;
24 24
25 using Google.Apis.Tests; 25 using Google.Apis.Tests;
26 26
27 namespace Google.Apis.Auth.OAuth2.Responses 27 namespace Google.Apis.Auth.OAuth2.Responses
28 { 28 {
29 /// <summary> 29 /// <summary>
30 /// Tests for <seealso cref="Google.Apis.Google.Apis.Auth.OAuth2.Responses.T okenResponse"/>. 30 /// Tests for <seealso cref="Google.Apis.Auth.OAuth2.Responses.TokenResponse "/>.
31 /// </summary> 31 /// </summary>
32 [TestFixture] 32 [TestFixture]
33 public class TokenResponseTests 33 public class TokenResponseTests
34 { 34 {
35 [Test] 35 [Test]
36 public void TestConstructor() 36 public void TestConstructor()
37 { 37 {
38 var response = new TokenResponse(); 38 var response = new TokenResponse();
39 Assert.Null(response.AccessToken); 39 Assert.Null(response.AccessToken);
40 Assert.Null(response.ExpiresInSeconds); 40 Assert.Null(response.ExpiresInSeconds);
(...skipping 18 matching lines...) Expand all
59 Assert.That(tokenResponse.ExpiresInSeconds, Is.EqualTo(1000)); 59 Assert.That(tokenResponse.ExpiresInSeconds, Is.EqualTo(1000));
60 } 60 }
61 61
62 [Test] 62 [Test]
63 public void IsExpired_True() 63 public void IsExpired_True()
64 { 64 {
65 var issued = DateTime.Now; 65 var issued = DateTime.Now;
66 var newNow = DateTime.Now.AddSeconds(200); 66 var newNow = DateTime.Now.AddSeconds(200);
67 67
68 var mockClock = new MockClock() 68 var mockClock = new MockClock()
69 { 69 {
70 Now = newNow 70 Now = newNow
71 }; 71 };
72 72
73 // Issued not set. 73 // Issued not set.
74 var response = new TokenResponse(); 74 var response = new TokenResponse();
75 Assert.True(response.IsExpired(mockClock)); 75 Assert.True(response.IsExpired(mockClock));
76 76
77 // ExpiresInSeconds is not set. 77 // ExpiresInSeconds is not set.
78 response = new TokenResponse() { Issued = issued }; 78 response = new TokenResponse() { Issued = issued };
79 Assert.True(response.IsExpired(mockClock)); 79 Assert.True(response.IsExpired(mockClock));
80 80
81 response = new TokenResponse() { ExpiresInSeconds = 1, Issued = issu ed }; 81 response = new TokenResponse() { ExpiresInSeconds = 1, Issued = issu ed };
(...skipping 10 matching lines...) Expand all
92 public void IsExpired_False() 92 public void IsExpired_False()
93 { 93 {
94 var issued = DateTime.Now; 94 var issued = DateTime.Now;
95 var newNow = DateTime.Now.AddSeconds(200); 95 var newNow = DateTime.Now.AddSeconds(200);
96 96
97 var mockClock = new MockClock() 97 var mockClock = new MockClock()
98 { 98 {
99 Now = newNow 99 Now = newNow
100 }; 100 };
101 101
102 var response = new TokenResponse() { ExpiresInSeconds = 141, Issued = issued }; 102 var response = new TokenResponse() { AccessToken = "a", ExpiresInSec onds = 141, Issued = issued };
103 Assert.False(response.IsExpired(mockClock)); 103 Assert.False(response.IsExpired(mockClock));
104 104
105 response = new TokenResponse() { ExpiresInSeconds = 142, Issued = is sued }; 105 response = new TokenResponse() { AccessToken = "a", ExpiresInSeconds = 142, Issued = issued };
106 Assert.False(response.IsExpired(mockClock)); 106 Assert.False(response.IsExpired(mockClock));
107 } 107 }
108 } 108 }
109 } 109 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b