LEFT | RIGHT |
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 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 | 60 |
61 /// <summary>Validates the deserialization result.</summary> | 61 /// <summary>Validates the deserialization result.</summary> |
62 private void CheckDeserializationResult(MockJsonSchema result) | 62 private void CheckDeserializationResult(MockJsonSchema result) |
63 { | 63 { |
64 Assert.NotNull(result); | 64 Assert.NotNull(result); |
65 Assert.That(result.Kind, Is.EqualTo("urlshortener#url")); | 65 Assert.That(result.Kind, Is.EqualTo("urlshortener#url")); |
66 Assert.That(result.LongURL, Is.EqualTo("http://google.com/")); | 66 Assert.That(result.LongURL, Is.EqualTo("http://google.com/")); |
67 Assert.That(result.Status, Is.Null); | 67 Assert.That(result.Status, Is.Null); |
68 } | 68 } |
69 | 69 |
70 /// <summary>Creates a client service for the given discovery version.</
summary> | 70 /// <summary>Creates a client service for the given features.</summary> |
71 private IClientService CreateClientService(Features? features = null) | 71 private IClientService CreateClientService(Features? features = null) |
72 { | 72 { |
73 var client = new MockClientService(); | 73 var client = new MockClientService(); |
74 if (features.HasValue) | 74 if (features.HasValue) |
75 { | 75 { |
76 client.SetFeatures(new[] { features.Value.GetStringValue() }); | 76 client.SetFeatures(new[] { features.Value.GetStringValue() }); |
77 } | 77 } |
78 | 78 |
79 return client; | 79 return client; |
80 } | 80 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 | 135 |
136 var client = CreateClientService(Features.LegacyDataResponse); | 136 var client = CreateClientService(Features.LegacyDataResponse); |
137 | 137 |
138 // Check if a response is serialized correctly | 138 // Check if a response is serialized correctly |
139 string result = client.SerializeObject(schema); | 139 string result = client.SerializeObject(schema); |
140 Assert.AreEqual(Response, result); | 140 Assert.AreEqual(Response, result); |
141 } | 141 } |
142 | 142 |
143 /// <summary>Tests serialization without data wrapping.</summary> | 143 /// <summary>Tests serialization without data wrapping.</summary> |
144 [Test] | 144 [Test] |
145 public void TestSerialization_WithDataWrapping() | 145 public void TestSerialization_WithoutDataWrapping() |
146 { | 146 { |
147 const string Response = @"{""kind"":""urlshortener#url"",""longUrl""
:""http://google.com/""}"; | 147 const string Response = @"{""kind"":""urlshortener#url"",""longUrl""
:""http://google.com/""}"; |
148 | 148 |
149 MockJsonSchema schema = new MockJsonSchema(); | 149 MockJsonSchema schema = new MockJsonSchema(); |
150 schema.Kind = "urlshortener#url"; | 150 schema.Kind = "urlshortener#url"; |
151 schema.LongURL = "http://google.com/"; | 151 schema.LongURL = "http://google.com/"; |
152 | 152 |
153 var client = CreateClientService(); | 153 var client = CreateClientService(); |
154 | 154 |
155 // Check if a response is serialized correctly. | 155 // Check if a response is serialized correctly. |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 | 362 |
363 // One execute interceptor (for adding the "Authenticate" header, | 363 // One execute interceptor (for adding the "Authenticate" header, |
364 Assert.That(service.HttpClient.MessageHandler.ExecuteInterceptors.Co
unt, Is.EqualTo(1)); | 364 Assert.That(service.HttpClient.MessageHandler.ExecuteInterceptors.Co
unt, Is.EqualTo(1)); |
365 Assert.That(service.HttpClient.MessageHandler.ExecuteInterceptors[0]
, | 365 Assert.That(service.HttpClient.MessageHandler.ExecuteInterceptors[0]
, |
366 Is.InstanceOf<AuthenticatorInterceptor>()); | 366 Is.InstanceOf<AuthenticatorInterceptor>()); |
367 } | 367 } |
368 | 368 |
369 #endregion | 369 #endregion |
370 } | 370 } |
371 } | 371 } |
LEFT | RIGHT |