LEFT | RIGHT |
1 /* | 1 /* |
2 Copyright 2011 Google Inc | 2 Copyright 2011 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 1090 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1101 var body = new MockRequest { Name = "long long name" }; | 1101 var body = new MockRequest { Name = "long long name" }; |
1102 using (var service = new MockClientService()) | 1102 using (var service = new MockClientService()) |
1103 { | 1103 { |
1104 // No ETag (ETag = null). | 1104 // No ETag (ETag = null). |
1105 var request = new TestClientServiceRequest(service, HttpConsts.G
et, body); | 1105 var request = new TestClientServiceRequest(service, HttpConsts.G
et, body); |
1106 var httpRequest = request.CreateRequest(); | 1106 var httpRequest = request.CreateRequest(); |
1107 Assert.That(httpRequest.Headers.IfMatch.Count, Is.EqualTo(0)); | 1107 Assert.That(httpRequest.Headers.IfMatch.Count, Is.EqualTo(0)); |
1108 Assert.That(httpRequest.Headers.IfNoneMatch.Count, Is.EqualTo(0)
); | 1108 Assert.That(httpRequest.Headers.IfNoneMatch.Count, Is.EqualTo(0)
); |
1109 | 1109 |
1110 // ETag has a value, but ETag action is ignored. | 1110 // ETag has a value, but ETag action is ignored. |
1111 body.ETag = "\"ETAG\""; | 1111 body.ETag = "\"ETAG_HERE\""; |
1112 request = new TestClientServiceRequest(service, HttpConsts.Get,
body); | 1112 request = new TestClientServiceRequest(service, HttpConsts.Get,
body); |
1113 request.ETagAction = ETagAction.Ignore; | 1113 request.ETagAction = ETagAction.Ignore; |
1114 httpRequest = request.CreateRequest(); | 1114 httpRequest = request.CreateRequest(); |
1115 Assert.That(httpRequest.Headers.IfMatch.Count, Is.EqualTo(0)); | 1115 Assert.That(httpRequest.Headers.IfMatch.Count, Is.EqualTo(0)); |
1116 Assert.That(httpRequest.Headers.IfNoneMatch.Count, Is.EqualTo(0)
); | 1116 Assert.That(httpRequest.Headers.IfNoneMatch.Count, Is.EqualTo(0)
); |
1117 | 1117 |
1118 // ETag has a value, so use default action (Get -> If-None-Match
). | 1118 // ETag has a value, so use default action (Get -> If-None-Match
). |
1119 request = new TestClientServiceRequest(service, HttpConsts.Get,
body); | 1119 request = new TestClientServiceRequest(service, HttpConsts.Get,
body); |
1120 httpRequest = request.CreateRequest(); | 1120 httpRequest = request.CreateRequest(); |
1121 Assert.That(httpRequest.Headers.IfMatch.Count, Is.EqualTo(0)); | 1121 Assert.That(httpRequest.Headers.IfMatch.Count, Is.EqualTo(0)); |
(...skipping 17 matching lines...) Expand all Loading... |
1139 | 1139 |
1140 // ETag has a value, default is override, use the specified ETag
action. | 1140 // ETag has a value, default is override, use the specified ETag
action. |
1141 request = new TestClientServiceRequest(service, HttpConsts.Get,
body); | 1141 request = new TestClientServiceRequest(service, HttpConsts.Get,
body); |
1142 request.ETagAction = ETagAction.IfMatch; | 1142 request.ETagAction = ETagAction.IfMatch; |
1143 httpRequest = request.CreateRequest(); | 1143 httpRequest = request.CreateRequest(); |
1144 Assert.That(httpRequest.Headers.IfNoneMatch.Count, Is.EqualTo(0)
); | 1144 Assert.That(httpRequest.Headers.IfNoneMatch.Count, Is.EqualTo(0)
); |
1145 Assert.That(httpRequest.Headers.IfMatch.Count, Is.EqualTo(1)); | 1145 Assert.That(httpRequest.Headers.IfMatch.Count, Is.EqualTo(1)); |
1146 Assert.That(httpRequest.Headers.IfMatch.First(), Is.EqualTo(new
EntityTagHeaderValue(body.ETag))); | 1146 Assert.That(httpRequest.Headers.IfMatch.First(), Is.EqualTo(new
EntityTagHeaderValue(body.ETag))); |
1147 | 1147 |
1148 // Fixing bug https://code.google.com/p/google-api-dotnet-client
/issues/detail?id=464. | 1148 // Fixing bug https://code.google.com/p/google-api-dotnet-client
/issues/detail?id=464. |
1149 // Etag contains a number | 1149 // If etag doesn't contain quotas - catch the format exception a
nd log. |
1150 body.ETag = "ETAG"; | 1150 body.ETag = "ETAG"; |
1151 request = new TestClientServiceRequest(service, HttpConsts.Post,
body); | 1151 request = new TestClientServiceRequest(service, HttpConsts.Post,
body); |
1152 httpRequest = request.CreateRequest(); | 1152 httpRequest = request.CreateRequest(); |
1153 Assert.That(httpRequest.Headers.IfNoneMatch.Count, Is.EqualTo(0)
); | 1153 Assert.That(httpRequest.Headers.IfNoneMatch.Count, Is.EqualTo(0)
); |
1154 Assert.That(httpRequest.Headers.IfMatch.Count, Is.EqualTo(1)); | 1154 Assert.That(httpRequest.Headers.IfMatch.Count, Is.EqualTo(0)); |
1155 Assert.That(httpRequest.Headers.IfMatch.First(), Is.EqualTo(new
EntityTagHeaderValue("\"ETAG\""))); | |
1156 | |
1157 } | 1155 } |
1158 } | 1156 } |
1159 | 1157 |
1160 /// <summary>Tests that get default ETag action works as expected.</summ
ary> | 1158 /// <summary>Tests that get default ETag action works as expected.</summ
ary> |
1161 [Test] | 1159 [Test] |
1162 public void GetDefaultETagActionTest() | 1160 public void GetDefaultETagActionTest() |
1163 { | 1161 { |
1164 Assert.AreEqual(ETagAction.IfNoneMatch, ClientServiceRequest<object>
.GetDefaultETagAction(HttpConsts.Get)); | 1162 Assert.AreEqual(ETagAction.IfNoneMatch, ClientServiceRequest<object>
.GetDefaultETagAction(HttpConsts.Get)); |
1165 Assert.AreEqual(ETagAction.IfMatch, ClientServiceRequest<object>.Get
DefaultETagAction(HttpConsts.Post)); | 1163 Assert.AreEqual(ETagAction.IfMatch, ClientServiceRequest<object>.Get
DefaultETagAction(HttpConsts.Post)); |
1166 Assert.AreEqual(ETagAction.IfMatch, ClientServiceRequest<object>.Get
DefaultETagAction(HttpConsts.Patch)); | 1164 Assert.AreEqual(ETagAction.IfMatch, ClientServiceRequest<object>.Get
DefaultETagAction(HttpConsts.Patch)); |
1167 Assert.AreEqual(ETagAction.IfMatch, ClientServiceRequest<object>.Get
DefaultETagAction(HttpConsts.Put)); | 1165 Assert.AreEqual(ETagAction.IfMatch, ClientServiceRequest<object>.Get
DefaultETagAction(HttpConsts.Put)); |
1168 Assert.AreEqual(ETagAction.IfMatch, ClientServiceRequest<object>.Get
DefaultETagAction(HttpConsts.Delete)); | 1166 Assert.AreEqual(ETagAction.IfMatch, ClientServiceRequest<object>.Get
DefaultETagAction(HttpConsts.Delete)); |
1169 Assert.AreEqual(ETagAction.Ignore, ClientServiceRequest<object>.GetD
efaultETagAction("INVALID")); | 1167 Assert.AreEqual(ETagAction.Ignore, ClientServiceRequest<object>.GetD
efaultETagAction("INVALID")); |
1170 } | 1168 } |
1171 | 1169 |
1172 #endregion | 1170 #endregion |
1173 } | 1171 } |
1174 } | 1172 } |
LEFT | RIGHT |