1. Google.Apis.Tests.ApplicationContextTests.GetLoggerDefaultTest
Code with line numbers
public GetLoggerDefaultTest(){(line 75)
Assert.IsInstanceOf<NullLogger>(ApplicationContext.Logger);(line 78)
}
This unit test case method tests get logger default test .
This unit test case validates that:
(1) ApplicationContext.Logger is a instance of NullLogger.
2. Google.Apis.Tests.ApplicationContextTests.RegisterLoggerTest
Code with line numbers
public RegisterLoggerTest(){(line 84)
Assert.IsInstanceOf<NullLogger>(ApplicationContext.Logger);(line 88)
Assert.DoesNotThrow();(line 91)
Assert.Throws<InvalidOperationException>();(line 94)
}
This unit test case method tests register logger test .
This unit test case validates that:
(1) ApplicationContext.Logger is a instance of NullLogger.
(2) The unit test does not throw an exception.
(3) The unit test throws an InvalidOperationException exception.
3. Google.Apis.Tests.Apis.Services.BaseClientServiceTest.TestDeserialization_WithDataWrapping
Code with line numbers
public TestDeserialization_WithDataWrapping(){(line 83)
string Response = @"{ ""data"" :
{
""kind"": ""urlshortener#url"",
""longUrl"": ""http://google.com/"",
}
}";(line 86)
var client = CreateClientService(Features.LegacyDataResponse);(line 94)
Assert.IsInstanceOf<NewtonsoftJsonSerializer>(client.Serializer);(line 97)
var stream = new MemoryStream(Encoding.Default.GetBytes(Response));(line 100)
var response = new HttpResponseMessage;(line 101)
CheckDeserializationResult(client.DeserializeResponse<MockJsonSchema>(response).Result);(line 102)
}
This unit test case method tests deserialization with data wrapping.
This unit test case validates that:
(1) client.Serializer is a instance of NewtonsoftJsonSerializer.
4. Google.Apis.Tests.Apis.Services.BaseClientServiceTest.TestDeserialization_WithoutDataWrapping
Code with line numbers
public TestDeserialization_WithoutDataWrapping(){(line 107)
string Response = @"{""kind"":""urlshortener#url"",""longUrl"":""http://google.com/""}";(line 110)
var client = CreateClientService();(line 113)
Assert.IsInstanceOf<NewtonsoftJsonSerializer>(client.Serializer);(line 116)
var stream = new MemoryStream(Encoding.Default.GetBytes(Response));(line 119)
var response = new HttpResponseMessage;(line 120)
CheckDeserializationResult(client.DeserializeResponse<MockJsonSchema>(response).Result);(line 121)
}
This unit test case method tests deserialization without data wrapping.
This unit test case validates that:
(1) client.Serializer is a instance of NewtonsoftJsonSerializer.
5. Google.Apis.Tests.Apis.Services.BaseClientServiceTest.TestSerialization_WithDataWrapping
Code with line numbers
public TestSerialization_WithDataWrapping(){(line 126)
string Response = "{\"data\":{\"kind\":\"urlshortener#url\",\"longUrl\":\"http://google.com/\"}}";(line 129)
MockJsonSchema schema = new MockJsonSchema();(line 132)
schema.Kind = "urlshortener#url";(line 133)
schema.LongURL = "http://google.com/";(line 134)
var client = CreateClientService(Features.LegacyDataResponse);(line 136)
string result = client.SerializeObject(schema);(line 139)
Assert.AreEqual(Response,result);(line 140)
}
This unit test case method tests serialization with data wrapping.
This unit test case includes following focal methods:
(1) string result = client.SerializeObject(schema);(@line 139)
This focal method is related to assertions at line 140
This unit test case validates that:
(1) result is equal to Response.
   result is obtained from
   1) variable client through slicing path
   2) variable schema through slicing path.
6. Google.Apis.Tests.Apis.Services.BaseClientServiceTest.TestSerialization_WithoutDataWrapping
Code with line numbers
public TestSerialization_WithoutDataWrapping(){(line 144)
string Response = @"{""kind"":""urlshortener#url"",""longUrl"":""http://google.com/""}";(line 147)
MockJsonSchema schema = new MockJsonSchema();(line 149)
schema.Kind = "urlshortener#url";(line 150)
schema.LongURL = "http://google.com/";(line 151)
var client = CreateClientService();(line 153)
string result = client.SerializeObject(schema);(line 156)
Assert.AreEqual(Response,result);(line 157)
}
This unit test case method tests serialization without data wrapping.
This unit test case includes following focal methods:
(1) string result = client.SerializeObject(schema);(@line 156)
This focal method is related to assertions at line 157
This unit test case validates that:
(1) result is equal to Response.
   result is obtained from
   1) variable client through slicing path
   2) variable schema through slicing path.
7. Google.Apis.Tests.Apis.Services.BaseClientServiceTest.TestDeserializationString
Code with line numbers
public TestDeserializationString(){(line 163)
string Response = @"{""kind"":""urlshortener#url"",""longUrl"":""http://google.com/""}";(line 166)
MockClientService client = new MockClientService();(line 168)
var stream = new MemoryStream(Encoding.Default.GetBytes(Response));(line 171)
var response = new HttpResponseMessage;(line 172)
string result = client.DeserializeResponse<string>(response).Result;(line 173)
Assert.AreEqual(Response,result);(line 174)
}
This unit test case method tests deserialization string .
This unit test case includes following focal methods:
(1) string result = client.DeserializeResponse(response).Result;(@line 173)
This focal method is related to assertions at line 174
This unit test case validates that:
(1) result is equal to Response.
   result is obtained from
   1) variable client through slicing path.
8. Google.Apis.Tests.Apis.Services.BaseClientServiceTest.TestErrorDeserialization
Code with line numbers
public TestErrorDeserialization(Features features){(line 178)
string ErrorResponse = @"{
""error"": {
""errors"": [
{
""domain"": ""global"",
""reason"": ""required"",
""message"": ""Required"",
""locationType"": ""parameter"",
""location"": ""resource.longUrl""
}
],
""code"": 400,
""message"": ""Required""
}
}";(line 182)
var client = CreateClientService(features);(line 199)
using()(line 201)
var response = new HttpResponseMessage;(line 203)
RequestError error = client.DeserializeError(response).Result;(line 204)
Assert.AreEqual(400,error.Code);(line 205)
Assert.AreEqual("Required",error.Message);(line 206)
Assert.AreEqual(1,error.Errors.Count);(line 207)
}
This unit test case method tests error deserialization .
This unit test case includes following focal methods:
(1) RequestError error = client.DeserializeError(response).Result;(@line 204)
This focal method is related to assertions at line 205, line 206, line 207
This unit test case validates that:
(1) error.Code is equal to 400.
   error is obtained from
   1) variable features through slicing path.
(2) error.Message is equal to "Required".
   error is obtained from
   1) variable features through slicing path.
(3) error.Errors.Count is equal to 1.
   error is obtained from
   1) variable features through slicing path.
9. Google.Apis.Tests.Apis.Services.BaseClientServiceTest.Constructor_DefaultValues
Code with line numbers
public Constructor_DefaultValues(){(line 256)
var service = new MockClientService(new BaseClientService.Initializer());(line 259)
Assert.NotNull(service.HttpClient);(line 260)
Assert.Null(service.HttpClientInitializer);(line 261)
Assert.True(service.GZipEnabled);(line 262)
Assert.That(service.HttpClient.MessageHandler.UnsuccessfulResponseHandlers.Count,Is.EqualTo(1));(line 265)
Assert.That(service.HttpClient.MessageHandler.UnsuccessfulResponseHandlers[0],Is.InstanceOf<BackOffHandler>());(line 266)
Assert.That(service.HttpClient.MessageHandler.ExecuteInterceptors.Count,Is.EqualTo(1));(line 270)
Assert.That(service.HttpClient.MessageHandler.ExecuteInterceptors[0],Is.InstanceOf<MaxUrlLengthInterceptor>());(line 271)
}
This unit test case method tests handle constructor default values .
This unit test case validates that:
(1) service.HttpClient is not null.
(2) service.HttpClientInitializer is null.
(3) service.GZipEnabled is true.
(4) service.HttpClient.MessageHandler.UnsuccessfulResponseHandlers.Count is equal to 1
(5) service.HttpClient.MessageHandler.UnsuccessfulResponseHandlers[0] Is.InstanceOf(
(6) service.HttpClient.MessageHandler.ExecuteInterceptors.Count is equal to 1
(7) service.HttpClient.MessageHandler.ExecuteInterceptors[0] Is.InstanceOf(
10. Google.Apis.Tests.Apis.Services.BaseClientServiceTest.TestGetWithUrlTooLongByDefault
Code with line numbers
public TestGetWithUrlTooLongByDefault(){(line 282)
var query = "q=" + new String('x',1020) + "&x=" + new String('y',1000);(line 286)
var uri = "http://www.example.com/";(line 287)
var requestUri = uri + "?" + query;(line 288)
var request = new HttpRequestMessage(HttpMethod.Get,requestUri);(line 289)
var messageHandler = new MockMessageHandler();(line 290)
using()(line 291)
service.HttpClient.SendAsync(request);(line 296)
Assert.That(requestUri.Length,Is.EqualTo(DefaultMaxUrlLength + 1));(line 298)
Assert.That(request.Method,Is.EqualTo(HttpMethod.Post));(line 300)
Assert.That(request.Headers.GetValues("X-HTTP-Method-Override").Single(),Is.EqualTo("GET"));(line 301)
Assert.That(request.Content.Headers.ContentType,Is.EqualTo(new MediaTypeHeaderValue("application/x-www-form-urlencoded")));(line 302)
Assert.That(request.RequestUri,Is.EqualTo(new Uri(uri)));(line 304)
Assert.That(messageHandler.RequestContent,Is.EqualTo(query));(line 305)
}
This unit test case method tests get with url too long by default.
This unit test case validates that:
(1) requestUri.Length is equal to DefaultMaxUrlLength + 1
   requestUri is obtained from
   1) variable uri through slicing path
   2) variable query through slicing path.
(2) request.Method is equal to HttpMethod.Post
   request is obtained from
   1) variable uri through slicing path
   2) variable query through slicing path.
(3) request.Headers.GetValues("X-HTTP-Method-Override").Single() is equal to "GET"
   request is obtained from
   1) variable uri through slicing path
   2) variable query through slicing path.
(4) request.Content.Headers.ContentType is equal to new MediaTypeHeaderValue("application/x-www-form-urlencoded")
   request is obtained from
   1) variable uri through slicing path
   2) variable query through slicing path.
(5) request.RequestUri is equal to new Uri(uri)
   request is obtained from
   1) variable uri through slicing path
   2) variable query through slicing path.
(6) messageHandler.RequestContent is equal to query
11. Google.Apis.Tests.Apis.Services.BaseClientServiceTest.TestGetWithUrlMaxLengthDisabled
Code with line numbers
public TestGetWithUrlMaxLengthDisabled(){(line 313)
var query = "q=" + new String('x',5000) + "&x=" + new String('y',6000);(line 316)
var uri = "http://www.example.com/";(line 317)
var requestUri = uri + "?" + query;(line 318)
var request = new HttpRequestMessage(HttpMethod.Get,requestUri);(line 319)
var messageHandler = new MockMessageHandler();(line 320)
var initializer = new BaseClientService.Initializer;(line 321)
using()(line 327)
service.HttpClient.SendAsync(request);(line 329)
Assert.That(request.RequestUri.ToString().Length,Is.EqualTo(requestUri.Length));(line 331)
Assert.That(request.Method,Is.EqualTo(HttpMethod.Get));(line 332)
Assert.That(request.Headers.Contains("X-HTTP-Method-Override"),Is.False);(line 333)
Assert.That(request.Content,Is.Null);(line 334)
Assert.That(request.RequestUri,Is.EqualTo(new Uri(requestUri)));(line 335)
}
This unit test case method tests get with url max length disabled.
This unit test case validates that:
(1) request.RequestUri.ToString().Length is equal to requestUri.Length
   request is obtained from
   1) variable uri through slicing path
   2) variable query through slicing path.
(2) request.Method is equal to HttpMethod.Get
   request is obtained from
   1) variable uri through slicing path
   2) variable query through slicing path.
(3) request.Headers.Contains("X-HTTP-Method-Override") Is.Fals
   request is obtained from
   1) variable uri through slicing path
   2) variable query through slicing path.
(4) request.Content Is.Nul
   request is obtained from
   1) variable uri through slicing path
   2) variable query through slicing path.
(5) request.RequestUri is equal to new Uri(requestUri)
   request is obtained from
   1) variable uri through slicing path
   2) variable query through slicing path.
12. Google.Apis.Tests.Apis.Requests.BatchRequestTest.ExecuteAsync_Test
Code with line numbers
public ExecuteAsync_Test(){(line 248)
SubtestExecuteAsync_Test(true);(line 251)
}
This unit test case method tests execute async test .
13. Google.Apis.Tests.Apis.Requests.BatchRequestTest.ExecuteAsync_Error_Test
Code with line numbers
public ExecuteAsync_Error_Test(){(line 254)
SubtestExecuteAsync_Test(false);(line 257)
}
This unit test case method tests execute async error test .
14. Google.Apis.Tests.Apis.Requests.BatchRequestTest.ExecuteAsync_NoCallback_Test
Code with line numbers
public ExecuteAsync_NoCallback_Test(){(line 331)
var handler = new BatchMessageHandler(true);(line 334)
var initializer = new BaseClientService.Initializer();(line 335)
using()(line 340)
var responses = new List();(line 342)
var batch = new BatchRequest(service);(line 343)
var request1 = new TestClientServiceRequest(service,new MockRequest);(line 344)
var request2 = new TestClientServiceRequest(service,new MockRequest);(line 349)
batch.Queue<MockResponse>(request1,null);(line 354)
batch.Queue<MockResponse>(request2,null);(line 355)
batch.ExecuteAsync().Wait();(line 356)
}
This unit test case method tests execute async no callback test .
15. Google.Apis.Tests.Apis.Requests.BatchRequestTest.CreateOuterRequestContent_Test
Code with line numbers
public CreateOuterRequestContent_Test(){(line 360)
using()(line 363)
var request1 = new TestClientServiceRequest(service,new MockRequest);(line 365)
var request2 = new TestClientServiceRequest(service,new MockRequest);(line 370)
var content = BatchRequest.CreateOuterRequestContent(new).Result;(line 376)
var requestStr = content.ReadAsStringAsync().Result;(line 377)
string boundary = null;(line 380)
using()(line 381)
var line = reader.ReadLine();(line 383)
boundary = line.Substring(2);(line 384)
Assert.AreEqual(ExpectedContentMessage.Replace("BOUNDARY",boundary),requestStr);(line 387)
}
This unit test case method tests create outer request content test .
This unit test case validates that:
(1) requestStr is equal to ExpectedContentMessage.Replace("BOUNDARY",boundary).
   requestStr is obtained from
   1) variable content through slicing path.
16. Google.Apis.Tests.Apis.Requests.BatchRequestTest.CreateIndividualRequest_Test
Code with line numbers
public CreateIndividualRequest_Test(){(line 391)
var expectedMessage = @"POST http://sample.com/5?q=20
If-Match: ""123""
Content-Type: application/json; charset=utf-8
Content-Length: 40
{""etag_key"":""\""123\"""",""name_key"":""Name""}
";(line 394)
using()(line 401)
var request = new TestClientServiceRequest(service,new MockRequest);(line 403)
var content = BatchRequest.CreateIndividualRequest(request).Result;(line 408)
var requestStr = content.ReadAsStringAsync().Result;(line 409)
Assert.AreEqual(expectedMessage,requestStr);(line 410)
}
This unit test case method tests create individual request test .
This unit test case validates that:
(1) requestStr is equal to expectedMessage.
   requestStr is obtained from
   1) variable request through slicing path.
17. Google.Apis.Tests.Apis.Requests.BatchRequestTest.CreateRequestContentString_Test
Code with line numbers
public CreateRequestContentString_Test(){(line 414)
var expectedMessage = @"GET http://test.com:2020/
Accept-Encoding: gzip
Content-Type: application/json
Content-Length: 11
hello world
";(line 417)
var request = new HttpRequestMessage(HttpMethod.Get,"http://test.com:2020");(line 424)
request.Content = new StringContent("hello world");(line 425)
request.Headers.AcceptEncoding.Add(new StringWithQualityHeaderValue("gzip"));(line 426)
request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");(line 427)
var requestStr = BatchRequest.CreateRequestContentString(request).Result;(line 429)
Assert.AreEqual(expectedMessage,requestStr);(line 430)
}
This unit test case method tests create request content string test .
This unit test case validates that:
(1) requestStr is equal to expectedMessage.
   requestStr is obtained from
   1) variable request through slicing path.
18. Google.Apis.Tests.Apis.Requests.ClientServiceRequestTest.ExecuteAsync_Cancel
Code with line numbers
public ExecuteAsync_Cancel(){(line 360)
SubtestExecuteAsync_Cancel(1);(line 363)
SubtestExecuteAsync_Cancel(5);(line 364)
SubtestExecuteAsync_Cancel(10);(line 365)
SubtestExecuteAsync_Cancel(11);(line 366)
}
This unit test case method tests execute async cancel .
19. Google.Apis.Tests.Apis.Requests.ClientServiceRequestTest.Execute_DisposeService
Code with line numbers
public Execute_DisposeService(){(line 417)
var handler = new MockMessageHandler();(line 420)
var initializer = new BaseClientService.Initializer();(line 421)
TestClientServiceRequest request;(line 426)
using()(line 427)
request = new TestClientServiceRequest(service,"POST",new MockRequest());(line 429)
Assert.Throws<ObjectDisposedException>();(line 434)
}
This unit test case method tests execute dispose service .
This unit test case validates that:
(1) The unit test throws an ObjectDisposedException exception.
20. Google.Apis.Tests.Apis.Requests.ClientServiceRequestTest.Execute_GZipEnabled
Code with line numbers
public Execute_GZipEnabled(){(line 484)
SubtestExecute_GZip(true,false);(line 487)
}
This unit test case method tests execute g zip enabled .
21. Google.Apis.Tests.Apis.Requests.ClientServiceRequestTest.Execute_GZipDisabled
Code with line numbers
public Execute_GZipDisabled(){(line 491)
SubtestExecute_GZip(false,false);(line 494)
}
This unit test case method tests execute g zip disabled .
22. Google.Apis.Tests.Apis.Requests.ClientServiceRequestTest.ExecuteAsync_GZipEnabled
Code with line numbers
public ExecuteAsync_GZipEnabled(){(line 498)
SubtestExecute_GZip(true,true);(line 501)
}
This unit test case method tests execute async g zip enabled .
23. Google.Apis.Tests.Apis.Requests.ClientServiceRequestTest.ExecuteAsync_GZipDisabled
Code with line numbers
public ExecuteAsync_GZipDisabled(){(line 505)
SubtestExecute_GZip(false,true);(line 508)
}
This unit test case method tests execute async g zip disabled .
24. Google.Apis.Tests.Apis.Requests.ClientServiceRequestTest.Execute_UnicodeCharacters
Code with line numbers
public Execute_UnicodeCharacters(){(line 512)
var handler = new TestBodyMessageHandler();(line 515)
var initializer = new BaseClientService.Initializer();(line 522)
using()(line 528)
handler.Serializer = service.Serializer;(line 530)
var request = new TestClientServiceRequest(service,"GET",handler.ExpectedRequestObject);(line 532)
var response = request.Execute();(line 533)
Assert.That(handler.Calls,Is.EqualTo(1));(line 534)
handler.ResponseObject.ETag = handler.ResponseETag;(line 537)
Assert.That(response,Is.EqualTo(handler.ResponseObject));(line 538)
}
This unit test case method tests execute unicode characters .
This unit test case includes following focal methods:
(1) var response = request.Execute();(@line 533)
This focal method is related to assertions at line 538
This unit test case validates that:
(1) handler.Calls is equal to 1
   handler is obtained from
   1) variable handler through slicing path.
(2) response is equal to handler.ResponseObject
   response is obtained from
   1) variable handler through slicing path.
25. Google.Apis.Tests.Apis.Requests.ClientServiceRequestTest.Execute_ThrowException_WithBackOff
Code with line numbers
public Execute_ThrowException_WithBackOff(){(line 574)
SubtestExecute_ThrowException(true);(line 577)
}
This unit test case method tests execute throw exception with back off.
26. Google.Apis.Tests.Apis.Requests.ClientServiceRequestTest.Execute_ThrowException_WithoutBackOff
Code with line numbers
public Execute_ThrowException_WithoutBackOff(){(line 583)
SubtestExecute_ThrowException(false);(line 586)
}
This unit test case method tests execute throw exception without back off.
27. Google.Apis.Tests.Apis.Requests.ClientServiceRequestTest.ExecuteAsync_ThrowException_WithBackOff
Code with line numbers
public ExecuteAsync_ThrowException_WithBackOff(){(line 630)
SubtestExecuteAsync_ThrowException(true);(line 633)
}
This unit test case method tests execute async throw exception with back off.
28. Google.Apis.Tests.Apis.Requests.ClientServiceRequestTest.ExecuteAsync_ThrowException_WithoutBackOff
Code with line numbers
public ExecuteAsync_ThrowException_WithoutBackOff(){(line 639)
SubtestExecuteAsync_ThrowException(false);(line 642)
}
This unit test case method tests execute async throw exception without back off.
29. Google.Apis.Tests.Apis.Requests.ClientServiceRequestTest.Execute_Error
Code with line numbers
public Execute_Error(){(line 646)
var handler = new ErrorMessageHanlder();(line 649)
var initializer = new BaseClientService.Initializer();(line 650)
using()(line 655)
var request = new TestClientServiceRequest(service,"GET",null);(line 657)
try(line 658)
request.Execute();(line 660)
Assert.Fail();(line 661)
catch(Exception ex)(line 663)
Assert.True(ex.Message.Contains(handler.ExpectedError),"Error message is invalid");(line 665)
Assert.That(handler.Calls,Is.EqualTo(1));(line 667)
}
This unit test case method tests execute error .
This unit test case validates that:
(1) Fail at line 661.
(2) ex.Message.Contains(handler.ExpectedError) is true.
(3) handler.Calls is equal to 1
30. Google.Apis.Tests.Apis.Requests.ClientServiceRequestTest.ExecuteAsync_Error
Code with line numbers
public ExecuteAsync_Error(){(line 672)
var handler = new ErrorMessageHanlder();(line 675)
var initializer = new BaseClientService.Initializer;(line 676)
using()(line 681)
var request = new TestClientServiceRequest(service,"GET",null);(line 683)
AutoResetEvent resetEvent = new AutoResetEvent(false);(line 684)
var task = request.ExecuteAsync();(line 685)
var error = string.Empty;(line 686)
task.ContinueWith(,TaskContinuationOptions.OnlyOnRanToCompletion);(line 687)
task.ContinueWith(,TaskContinuationOptions.NotOnRanToCompletion);(line 692)
resetEvent.WaitOne();(line 698)
Assert.True(error.Contains(handler.ExpectedError),"Error message is invalid");(line 699)
Assert.That(handler.Calls,Is.EqualTo(1));(line 700)
}
This unit test case method tests execute async error .
This unit test case validates that:
(1) error.Contains(handler.ExpectedError) is true.
(2) handler.Calls is equal to 1
31. Google.Apis.Tests.Apis.Requests.ClientServiceRequestTest.ExecuteAsync_Simultaneously
Code with line numbers
public ExecuteAsync_Simultaneously(){(line 705)
var tasks = new List();(line 708)
var handler = new ConcurrentCallsHandler();(line 709)
var initializer = new BaseClientService.Initializer();(line 710)
using()(line 716)
int calls = 100;(line 718)
handler.Serializer = service.Serializer;(line 719)
CountdownEvent ce = new CountdownEvent(calls);(line 721)
foreach(var i)(line 722)
var request = new TestClientServiceRequest(service,"GET",null);(line 724)
var task = request.ExecuteAsync();(line 725)
task.ContinueWith();(line 726)
tasks.Add(task);(line 727)
ce.Wait();(line 729)
for(var i = 1; i <= tasks.Count; ++ i)(line 731)
var response = tasks[i - 1].Result;(line 733)
var nameIndex = i % 2 == 0 ? i + 1 : i % 10;(line 739)
Assert.That(response.Name,Is.EqualTo("Name-" + nameIndex));(line 740)
Assert.That(handler.Calls,Is.EqualTo(calls + calls / 2));(line 744)
}
This unit test case method tests execute async simultaneously .
This unit test case validates that:
(1) response.Name is equal to "Name-" + nameIndex
   response is obtained from
   1) variable tasks through slicing path.
(2) handler.Calls is equal to calls + calls / 2
32. Google.Apis.Tests.Apis.Requests.ClientServiceRequestTest.ExecuteAsStream
Code with line numbers
public ExecuteAsStream(){(line 798)
SubtestExecuteAsStream(false);(line 801)
}
This unit test case method tests execute client service request test as stream.
33. Google.Apis.Tests.Apis.Requests.ClientServiceRequestTest.ExecuteAsStreamAsync
Code with line numbers
public ExecuteAsStreamAsync(){(line 805)
SubtestExecuteAsStream(true);(line 808)
}
This unit test case method tests execute client service request test as stream async.
34. Google.Apis.Tests.Apis.Requests.ClientServiceRequestTest.CreateRequest_QueryParameters
Code with line numbers
public CreateRequest_QueryParameters(){(line 886)
using()(line 889)
var request = new ClientServiceRequestWithQueryParameters(service,"GET",null);(line 891)
request.Required = "a";(line 892)
request.OptionalWithValue = "b";(line 893)
request.OptionalWithValue2 = "DoesNotDisplay";(line 894)
request.OptionalNull = null;(line 895)
request.OptionalEmpty = string.Empty;(line 896)
var httpRequest = request.CreateRequest();(line 897)
Assert.That(httpRequest.RequestUri,Is.EqualTo(new Uri("https://build_request_params/restPath0?required=a&optionalWithValue=b&optionalEmpty")));(line 898)
}
This unit test case method tests create request query parameters .
This unit test case includes following focal methods:
(1) var httpRequest = request.CreateRequest();(@line 897)
This focal method is related to assertions at line 898
This unit test case validates that:
(1) httpRequest.RequestUri is equal to new Uri("https://build_request_params/restPath0?required=a&optionalWithValue=b&optionalEmpty")
   httpRequest is obtained from
   1) variable request through slicing path.
35. Google.Apis.Tests.Apis.Requests.ClientServiceRequestTest.CreateRequest_QueryParameterIsMissing
Code with line numbers
public CreateRequest_QueryParameterIsMissing(){(line 904)
using()(line 907)
var request = new ClientServiceRequestWithQueryParameters(service,"GET",null);(line 909)
try(line 911)
var httpRequest = request.CreateRequest();(line 913)
Assert.Fail();(line 914)
catch(GoogleApiException ex)(line 916)
Assert.True(ex.Message.Contains("Parameter \"required\" is missing"),"Exception with missing parameter should be thrown");(line 918)
}
This unit test case method tests create request query parameter is missing .
This unit test case validates that:
(1) Fail at line 914.
(2) ex.Message.Contains("Parameter \"required\" is missing") is true.
36. Google.Apis.Tests.Apis.Requests.ClientServiceRequestTest.CreateRequest_QueryDateParameter
Code with line numbers
public CreateRequest_QueryDateParameter(){(line 942)
using()(line 945)
var request = new ClientServiceRequestWithDateQueryParameter(service,"GET",null);(line 948)
var httpRequest = request.CreateRequest();(line 949)
Assert.That(httpRequest.RequestUri,Is.EqualTo(new Uri("https://build_request_params/restPath0")));(line 950)
DateTime date = new DateTime(2002,2,25,12,57,32,777,DateTimeKind.Utc);(line 953)
request.Min = date;(line 954)
httpRequest = request.CreateRequest();(line 955)
Assert.That(httpRequest.RequestUri,Is.EqualTo(new Uri("https://build_request_params/restPath0?min_time=2002-02-25T12:57:32.777Z")));(line 956)
}
This unit test case method tests create request query date parameter .
This unit test case includes following focal methods:
(1) var httpRequest = request.CreateRequest();(@line 949)
This focal method is related to assertions at line 950
(2) httpRequest = request.CreateRequest();(@line 955)
This focal method is related to assertions at line 956
This unit test case validates that:
(1) httpRequest.RequestUri is equal to new Uri("https://build_request_params/restPath0")
   httpRequest is obtained from
   1) variable request through slicing path.
(2) httpRequest.RequestUri is equal to new Uri("https://build_request_params/restPath0?min_time=2002-02-25T12:57:32.777Z")
   httpRequest is obtained from
   1) variable date through slicing path.
37. Google.Apis.Tests.Apis.Requests.ClientServiceRequestTest.CreateRequest_PathParameters
Code with line numbers
public CreateRequest_PathParameters(){(line 998)
using()(line 1001)
var request = new ClientServiceRequestWithPathParameters(service,"GET",null);(line 1003)
request.TestParameterA = 42;(line 1004)
request.TestParameterB = 43;(line 1005)
request.TestParameterC = 44;(line 1006)
var httpRequest = request.CreateRequest();(line 1007)
Assert.That(httpRequest.RequestUri,Is.EqualTo(new Uri("https://build_request_params/restPath/42/something/43")));(line 1008)
}
This unit test case method tests create request path parameters .
This unit test case includes following focal methods:
(1) var httpRequest = request.CreateRequest();(@line 1007)
This focal method is related to assertions at line 1008
This unit test case validates that:
(1) httpRequest.RequestUri is equal to new Uri("https://build_request_params/restPath/42/something/43")
   httpRequest is obtained from
   1) variable request through slicing path.
38. Google.Apis.Tests.Apis.Requests.ClientServiceRequestTest.CreateRequest_DeveloperKey
Code with line numbers
public CreateRequest_DeveloperKey(){(line 1021)
var initializer = new BaseClientService.Initializer;(line 1024)
using()(line 1029)
var request = new TestClientServiceRequest(service,"GET",null);(line 1031)
var httpRequest = request.CreateRequest();(line 1032)
Assert.That(httpRequest.RequestUri,Is.EqualTo(new Uri("https://build_request_params/restPath0?key=" + SimpleDeveloperKey)));(line 1033)
}
This unit test case method tests create request developer key .
This unit test case includes following focal methods:
(1) var httpRequest = request.CreateRequest();(@line 1032)
This focal method is related to assertions at line 1033
This unit test case validates that:
(1) httpRequest.RequestUri is equal to new Uri("https://build_request_params/restPath0?key=" + SimpleDeveloperKey)
   httpRequest is obtained from
   1) variable request through slicing path.
39. Google.Apis.Tests.Apis.Requests.ClientServiceRequestTest.CreateRequest_DeveloperKey_RequiresEscape
Code with line numbers
public CreateRequest_DeveloperKey_RequiresEscape(){(line 1039)
var initializer = new BaseClientService.Initializer;(line 1042)
using()(line 1047)
var request = new TestClientServiceRequest(service,"GET",null);(line 1049)
var httpRequest = request.CreateRequest();(line 1050)
Assert.That(httpRequest.RequestUri,Is.EqualTo(new Uri("https://build_request_params/restPath0?key=%3F%26%5E%25%20%20ABC123")));(line 1051)
}
This unit test case method tests create request developer key requires escape .
This unit test case includes following focal methods:
(1) var httpRequest = request.CreateRequest();(@line 1050)
This focal method is related to assertions at line 1051
This unit test case validates that:
(1) httpRequest.RequestUri is equal to new Uri("https://build_request_params/restPath0?key=%3F%26%5E%25%20%20ABC123")
   httpRequest is obtained from
   1) variable request through slicing path.
40. Google.Apis.Tests.Apis.Requests.ClientServiceRequestTest.CreateRequest_UnsupportedMethods
Code with line numbers
public CreateRequest_UnsupportedMethods(){(line 1063)
using()(line 1066)
var request = new TestClientServiceRequest(service,"Unsupported",null);(line 1068)
Assert.Throws<ArgumentOutOfRangeException>();(line 1069)
}
This unit test case method tests create request unsupported methods .
This unit test case validates that:
(1) The unit test throws an ArgumentOutOfRangeException exception.
41. Google.Apis.Tests.Apis.Requests.ClientServiceRequestTest.CreateRequest_SupportedMethods
Code with line numbers
public CreateRequest_SupportedMethods(){(line 1074)
SubtestCreateRequest_SupportedMethod(HttpConsts.Get);(line 1077)
SubtestCreateRequest_SupportedMethod(HttpConsts.Put);(line 1078)
SubtestCreateRequest_SupportedMethod(HttpConsts.Post);(line 1079)
SubtestCreateRequest_SupportedMethod(HttpConsts.Patch);(line 1080)
SubtestCreateRequest_SupportedMethod(HttpConsts.Delete);(line 1081)
}
This unit test case method tests create request supported methods .
42. Google.Apis.Tests.Apis.Requests.ClientServiceRequestTest.CreateRequest_ETag
Code with line numbers
public CreateRequest_ETag(){(line 1098)
var body = new MockRequest;(line 1101)
using()(line 1102)
var request = new TestClientServiceRequest(service,HttpConsts.Get,body);(line 1105)
var httpRequest = request.CreateRequest();(line 1106)
Assert.That(httpRequest.Headers.IfMatch.Count,Is.EqualTo(0));(line 1107)
Assert.That(httpRequest.Headers.IfNoneMatch.Count,Is.EqualTo(0));(line 1108)
body.ETag = "\"ETAG_HERE\"";(line 1111)
request = new TestClientServiceRequest(service,HttpConsts.Get,body);(line 1112)
request.ETagAction = ETagAction.Ignore;(line 1113)
httpRequest = request.CreateRequest();(line 1114)
Assert.That(httpRequest.Headers.IfMatch.Count,Is.EqualTo(0));(line 1115)
Assert.That(httpRequest.Headers.IfNoneMatch.Count,Is.EqualTo(0));(line 1116)
request = new TestClientServiceRequest(service,HttpConsts.Get,body);(line 1119)
httpRequest = request.CreateRequest();(line 1120)
Assert.That(httpRequest.Headers.IfMatch.Count,Is.EqualTo(0));(line 1121)
Assert.That(httpRequest.Headers.IfNoneMatch.Count,Is.EqualTo(1));(line 1122)
Assert.That(httpRequest.Headers.IfNoneMatch.First(),Is.EqualTo(new EntityTagHeaderValue(body.ETag)));(line 1123)
request = new TestClientServiceRequest(service,HttpConsts.Post,body);(line 1126)
httpRequest = request.CreateRequest();(line 1127)
Assert.That(httpRequest.Headers.IfNoneMatch.Count,Is.EqualTo(0));(line 1128)
Assert.That(httpRequest.Headers.IfMatch.Count,Is.EqualTo(1));(line 1129)
Assert.That(httpRequest.Headers.IfMatch.First(),Is.EqualTo(new EntityTagHeaderValue(body.ETag)));(line 1130)
request = new TestClientServiceRequest(service,HttpConsts.Post,body);(line 1133)
request.ETagAction = ETagAction.IfNoneMatch;(line 1134)
httpRequest = request.CreateRequest();(line 1135)
Assert.That(httpRequest.Headers.IfMatch.Count,Is.EqualTo(0));(line 1136)
Assert.That(httpRequest.Headers.IfNoneMatch.Count,Is.EqualTo(1));(line 1137)
Assert.That(httpRequest.Headers.IfNoneMatch.First(),Is.EqualTo(new EntityTagHeaderValue(body.ETag)));(line 1138)
request = new TestClientServiceRequest(service,HttpConsts.Get,body);(line 1141)
request.ETagAction = ETagAction.IfMatch;(line 1142)
httpRequest = request.CreateRequest();(line 1143)
Assert.That(httpRequest.Headers.IfNoneMatch.Count,Is.EqualTo(0));(line 1144)
Assert.That(httpRequest.Headers.IfMatch.Count,Is.EqualTo(1));(line 1145)
Assert.That(httpRequest.Headers.IfMatch.First(),Is.EqualTo(new EntityTagHeaderValue(body.ETag)));(line 1146)
body.ETag = "ETAG";(line 1150)
request = new TestClientServiceRequest(service,HttpConsts.Post,body);(line 1151)
httpRequest = request.CreateRequest();(line 1152)
Assert.That(httpRequest.Headers.IfNoneMatch.Count,Is.EqualTo(0));(line 1153)
Assert.That(httpRequest.Headers.IfMatch.Count,Is.EqualTo(0));(line 1154)
}
This unit test case method tests create request e tag .
This unit test case includes following focal methods:
(1) var httpRequest = request.CreateRequest();(@line 1106)
This focal method is related to assertions at line 1107, line 1108
(2) httpRequest = request.CreateRequest();(@line 1114)
This focal method is related to assertions at line 1115, line 1116
(3) httpRequest = request.CreateRequest();(@line 1120)
This focal method is related to assertions at line 1121, line 1122, line 1123
(4) httpRequest = request.CreateRequest();(@line 1127)
This focal method is related to assertions at line 1128, line 1129, line 1130
(5) httpRequest = request.CreateRequest();(@line 1135)
This focal method is related to assertions at line 1136, line 1137, line 1138
(6) httpRequest = request.CreateRequest();(@line 1143)
This focal method is related to assertions at line 1144, line 1145, line 1146
(7) httpRequest = request.CreateRequest();(@line 1152)
This focal method is related to assertions at line 1153, line 1154
This unit test case validates that:
(1) httpRequest.Headers.IfMatch.Count is equal to 0
   httpRequest is obtained from
   1) variable body through slicing path.
(2) httpRequest.Headers.IfNoneMatch.Count is equal to 0
   httpRequest is obtained from
   1) variable body through slicing path.
(3) httpRequest.Headers.IfMatch.Count is equal to 0
   httpRequest is obtained from
   1) variable body through slicing path.
(4) httpRequest.Headers.IfNoneMatch.Count is equal to 0
   httpRequest is obtained from
   1) variable body through slicing path.
(5) httpRequest.Headers.IfMatch.Count is equal to 0
   httpRequest is obtained from
   1) variable body through slicing path.
(6) httpRequest.Headers.IfNoneMatch.Count is equal to 1
   httpRequest is obtained from
   1) variable body through slicing path.
(7) httpRequest.Headers.IfNoneMatch.First() is equal to new EntityTagHeaderValue(body.ETag)
   httpRequest is obtained from
   1) variable body through slicing path.
(8) httpRequest.Headers.IfNoneMatch.Count is equal to 0
   httpRequest is obtained from
   1) variable body through slicing path.
(9) httpRequest.Headers.IfMatch.Count is equal to 1
   httpRequest is obtained from
   1) variable body through slicing path.
(10) httpRequest.Headers.IfMatch.First() is equal to new EntityTagHeaderValue(body.ETag)
   httpRequest is obtained from
   1) variable body through slicing path.
(11) httpRequest.Headers.IfMatch.Count is equal to 0
   httpRequest is obtained from
   1) variable body through slicing path.
(12) httpRequest.Headers.IfNoneMatch.Count is equal to 1
   httpRequest is obtained from
   1) variable body through slicing path.
(13) httpRequest.Headers.IfNoneMatch.First() is equal to new EntityTagHeaderValue(body.ETag)
   httpRequest is obtained from
   1) variable body through slicing path.
(14) httpRequest.Headers.IfNoneMatch.Count is equal to 0
   httpRequest is obtained from
   1) variable body through slicing path.
(15) httpRequest.Headers.IfMatch.Count is equal to 1
   httpRequest is obtained from
   1) variable body through slicing path.
(16) httpRequest.Headers.IfMatch.First() is equal to new EntityTagHeaderValue(body.ETag)
   httpRequest is obtained from
   1) variable body through slicing path.
(17) httpRequest.Headers.IfNoneMatch.Count is equal to 0
   httpRequest is obtained from
   1) variable body through slicing path.
(18) httpRequest.Headers.IfMatch.Count is equal to 0
   httpRequest is obtained from
   1) variable body through slicing path.
43. Google.Apis.Tests.Apis.Requests.ClientServiceRequestTest.GetDefaultETagActionTest
Code with line numbers
public GetDefaultETagActionTest(){(line 1159)
Assert.AreEqual(ETagAction.IfNoneMatch,ClientServiceRequest.GetDefaultETagAction(HttpConsts.Get));(line 1162)
Assert.AreEqual(ETagAction.IfMatch,ClientServiceRequest.GetDefaultETagAction(HttpConsts.Post));(line 1163)
Assert.AreEqual(ETagAction.IfMatch,ClientServiceRequest.GetDefaultETagAction(HttpConsts.Patch));(line 1164)
Assert.AreEqual(ETagAction.IfMatch,ClientServiceRequest.GetDefaultETagAction(HttpConsts.Put));(line 1165)
Assert.AreEqual(ETagAction.IfMatch,ClientServiceRequest.GetDefaultETagAction(HttpConsts.Delete));(line 1166)
Assert.AreEqual(ETagAction.Ignore,ClientServiceRequest.GetDefaultETagAction("INVALID"));(line 1167)
}
This unit test case method tests get default e tag action test .
This unit test case validates that:
(1) ClientServiceRequest.GetDefaultETagAction(HttpConsts.Get) is equal to ETagAction.IfNoneMatch.
(2) ClientServiceRequest.GetDefaultETagAction(HttpConsts.Post) is equal to ETagAction.IfMatch.
(3) ClientServiceRequest.GetDefaultETagAction(HttpConsts.Patch) is equal to ETagAction.IfMatch.
(4) ClientServiceRequest.GetDefaultETagAction(HttpConsts.Put) is equal to ETagAction.IfMatch.
(5) ClientServiceRequest.GetDefaultETagAction(HttpConsts.Delete) is equal to ETagAction.IfMatch.
(6) ClientServiceRequest.GetDefaultETagAction("INVALID") is equal to ETagAction.Ignore.
44. Google.Apis.Tests.Apis.Requests.ParameterCollectionTest.ConstructTest
Code with line numbers
public ConstructTest(){(line 32)
Assert.DoesNotThrow();(line 35)
}
This unit test case method tests construct test .
This unit test case validates that:
(1) The unit test does not throw an exception.
45. Google.Apis.Tests.Apis.Requests.ParameterCollectionTest.MultipleAddTest
Code with line numbers
public MultipleAddTest(){(line 39)
var col = new ParameterCollection();(line 42)
Assert.That(col.Count,Is.EqualTo(0));(line 45)
CollectionAssert.AreEqual(new string[0],col.GetAllMatches("test"));(line 46)
col.Add("black","hole");(line 49)
Assert.That(col.Count,Is.EqualTo(1));(line 50)
CollectionAssert.AreEqual(new,col.GetAllMatches("black"));(line 51)
col.Add("white","dwarf");(line 54)
Assert.That(col.Count,Is.EqualTo(2));(line 55)
CollectionAssert.AreEqual(new,col.GetAllMatches("black"));(line 56)
CollectionAssert.AreEqual(new,col.GetAllMatches("white"));(line 57)
}
This unit test case method tests handle multiple add test .
This unit test case includes following focal methods:
(1) col.Add("black","hole");(@line 49)
This focal method is related to assertions at line 50
(2) col.Add("white","dwarf");(@line 54)
This focal method is related to assertions at line 55
This unit test case validates that:
(1) col.Count is equal to 0
(2) col.Count is equal to 1
(3) col.Count is equal to 2
46. Google.Apis.Tests.Apis.Requests.ParameterCollectionTest.DuplicateTest
Code with line numbers
public DuplicateTest(){(line 61)
var col = new ParameterCollection();(line 64)
col.Add("chocolate","cookie");(line 65)
col.Add("chocolate","bar");(line 66)
col.Add("chocolate","pudding");(line 67)
Assert.That(col.Count,Is.EqualTo(3));(line 68)
CollectionAssert.AreEqual(new,col.GetAllMatches("chocolate"));(line 69)
}
This unit test case method tests duplicate test .
This unit test case includes following focal methods:
(1) col.Add("chocolate","pudding");(@line 67)
This focal method is related to assertions at line 68
This unit test case validates that:
(1) col.Count is equal to 3
47. Google.Apis.Tests.Apis.Requests.ParameterCollectionTest.FromQueryStringTest
Code with line numbers
public FromQueryStringTest(){(line 73)
string query = "q=foo1&q=bar&q=foo2&chocolate=bar";(line 76)
var collection = ParameterCollection.FromQueryString(query);(line 77)
Assert.That(collection.Count,Is.EqualTo(4));(line 78)
CollectionAssert.AreEqual(new,collection.GetAllMatches("q"));(line 79)
CollectionAssert.AreEqual(new,collection.GetAllMatches("chocolate"));(line 80)
}
This unit test case method tests convert from query string test .
This unit test case validates that:
(1) collection.Count is equal to 4
   collection is obtained from
   1) variable query through slicing path.
48. Google.Apis.Tests.Apis.Requests.ParameterCollectionTest.FromQueryStringTest_Invalid
Code with line numbers
public FromQueryStringTest_Invalid(){(line 84)
string query = "q=foo1&q=bar&q=foo2=invalid&chocolate=bar";(line 87)
Assert.Throws<ArgumentException>();(line 88)
}
This unit test case method tests convert from query string test invalid .
This unit test case validates that:
(1) The unit test throws an ArgumentException exception.
49. Google.Apis.Tests.Apis.Requests.ParameterCollectionTest.FromDictionaryTest
Code with line numbers
public FromDictionaryTest(){(line 92)
Dictionary<string,object> dictionary = new Dictionary();(line 95)
dictionary.Add("q",new string);(line 96)
dictionary.Add("q2",new object);(line 97)
dictionary.Add("q3",Repeatable(new));(line 98)
dictionary.Add("chocolate","bar");(line 99)
dictionary.Add("test",null);(line 100)
var collection = ParameterCollection.FromDictionary(dictionary);(line 103)
CollectionAssert.AreEqual(new,collection.GetAllMatches("q"));(line 104)
CollectionAssert.AreEqual(new,collection.GetAllMatches("q2"));(line 105)
CollectionAssert.AreEqual(new,collection.GetAllMatches("q3"));(line 106)
CollectionAssert.AreEqual(new,collection.GetAllMatches("chocolate"));(line 107)
CollectionAssert.AreEqual(new string,collection.GetAllMatches("test"));(line 108)
Assert.That(collection.Count,Is.EqualTo(8));(line 109)
}
This unit test case method tests convert from dictionary test .
This unit test case includes following focal methods:
(1) CollectionAssert.AreEqual(new string,collection.GetAllMatches("test"));(@line 108)
This focal method is related to assertions at line 109
This unit test case validates that:
(1) collection.Count is equal to 8
   collection is obtained from
   1) variable dictionary through slicing path.
50. Google.Apis.Tests.Apis.Requests.ParameterValidatorTest.ValidateRegexEmptyNeedsDataTest
Code with line numbers
public ValidateRegexEmptyNeedsDataTest(){(line 29)
var parameter = new Parameter;(line 32)
Assert.IsFalse(ParameterValidator.ValidateRegex(parameter,""));(line 33)
}
This unit test case method tests validate regex empty needs data test .
This unit test case validates that:
(1) ParameterValidator.ValidateRegex(parameter,"") is false.
51. Google.Apis.Tests.Apis.Requests.ParameterValidatorTest.ValidateRegexTest
Code with line numbers
public ValidateRegexTest(){(line 37)
var parameter = new Parameter;(line 40)
Assert.IsTrue(ParameterValidator.ValidateRegex(parameter,"Test"));(line 41)
}
This unit test case method tests validate regex test .
This unit test case validates that:
(1) ParameterValidator.ValidateRegex(parameter,"Test") is true.
52. Google.Apis.Tests.Apis.Requests.RequestBuilderTest.TestBasicWebRequest
Code with line numbers
public TestBasicWebRequest(){(line 33)
var builder = new RequestBuilder();(line 36)
var request = builder.CreateRequest();(line 41)
Assert.That(request.Method,Is.EqualTo(HttpMethod.Get));(line 42)
Assert.That(request.RequestUri,Is.EqualTo(new Uri("http://www.example.com/")));(line 43)
}
This unit test case method tests basic web request .
This unit test case includes following focal methods:
(1) var request = builder.CreateRequest();(@line 41)
This focal method is related to assertions at line 42, line 43
This unit test case validates that:
(1) request.Method is equal to HttpMethod.Get
   request is obtained from
   1) variable builder through slicing path.
(2) request.RequestUri is equal to new Uri("http://www.example.com/")
   request is obtained from
   1) variable builder through slicing path.
53. Google.Apis.Tests.Apis.Requests.RequestBuilderTest.TestPostWebRequest
Code with line numbers
public TestPostWebRequest(){(line 47)
var builder = new RequestBuilder();(line 50)
var request = builder.CreateRequest();(line 56)
Assert.That(request.Method,Is.EqualTo(HttpMethod.Post));(line 57)
Assert.That(request.RequestUri,Is.EqualTo(new Uri("http://www.example.com/")));(line 58)
}
This unit test case method tests post web request .
This unit test case includes following focal methods:
(1) var request = builder.CreateRequest();(@line 56)
This focal method is related to assertions at line 57, line 58
This unit test case validates that:
(1) request.Method is equal to HttpMethod.Post
   request is obtained from
   1) variable builder through slicing path.
(2) request.RequestUri is equal to new Uri("http://www.example.com/")
   request is obtained from
   1) variable builder through slicing path.
54. Google.Apis.Tests.Apis.Requests.RequestBuilderTest.TestBasePlusPathMath
Code with line numbers
public TestBasePlusPathMath(){(line 62)
var builder = new RequestBuilder();(line 65)
var request = builder.CreateRequest();(line 72)
Assert.That(request.Method,Is.EqualTo(HttpMethod.Put));(line 73)
Assert.That(request.RequestUri,Is.EqualTo(new Uri("http://www.example.com/test/path")));(line 74)
}
This unit test case method tests base plus path math .
This unit test case includes following focal methods:
(1) var request = builder.CreateRequest();(@line 72)
This focal method is related to assertions at line 73, line 74
This unit test case validates that:
(1) request.Method is equal to HttpMethod.Put
   request is obtained from
   1) variable builder through slicing path.
(2) request.RequestUri is equal to new Uri("http://www.example.com/test/path")
   request is obtained from
   1) variable builder through slicing path.
55. Google.Apis.Tests.Apis.Requests.RequestBuilderTest.TestSingleQueryParameter
Code with line numbers
public TestSingleQueryParameter(){(line 78)
var builder = new RequestBuilder();(line 81)
builder.AddParameter(RequestParameterType.Query,"testQueryParam","testValue");(line 86)
var request = builder.CreateRequest();(line 88)
Assert.That(request.RequestUri,Is.EqualTo(new Uri("http://www.example.com/?testQueryParam=testValue")));(line 89)
}
This unit test case method tests single query parameter .
This unit test case includes following focal methods:
(1) var request = builder.CreateRequest();(@line 88)
This focal method is related to assertions at line 89
This unit test case validates that:
(1) request.RequestUri is equal to new Uri("http://www.example.com/?testQueryParam=testValue")
   request is obtained from
   1) variable builder through slicing path.
56. Google.Apis.Tests.Apis.Requests.RequestBuilderTest.TestMultipleQueryParameter
Code with line numbers
public TestMultipleQueryParameter(){(line 93)
var builder = new RequestBuilder();(line 96)
builder.AddParameter(RequestParameterType.Query,"testQueryParamA","testValueA");(line 100)
builder.AddParameter(RequestParameterType.Query,"testQueryParamB","testValueB");(line 101)
var request = builder.CreateRequest();(line 103)
Assert.That(request.RequestUri,Is.EqualTo(new Uri("http://www.example.com/?testQueryParamA=testValueA&testQueryParamB=testValueB")));(line 104)
}
This unit test case method tests multiple query parameter .
This unit test case includes following focal methods:
(1) var request = builder.CreateRequest();(@line 103)
This focal method is related to assertions at line 104
This unit test case validates that:
(1) request.RequestUri is equal to new Uri("http://www.example.com/?testQueryParamA=testValueA&testQueryParamB=testValueB")
   request is obtained from
   1) variable builder through slicing path.
57. Google.Apis.Tests.Apis.Requests.RequestBuilderTest.TestQueryParameterWithUrlEncode
Code with line numbers
public TestQueryParameterWithUrlEncode(){(line 109)
var builder = new RequestBuilder();(line 112)
builder.AddParameter(RequestParameterType.Query,"test Query Param","test %va/ue");(line 117)
var request = builder.CreateRequest();(line 119)
Assert.That(request.RequestUri,Is.EqualTo(new Uri("http://www.example.com/?test%20Query%20Param=test%20%25va%2Fue")));(line 120)
}
This unit test case method tests query parameter with url encode.
This unit test case includes following focal methods:
(1) var request = builder.CreateRequest();(@line 119)
This focal method is related to assertions at line 120
This unit test case validates that:
(1) request.RequestUri is equal to new Uri("http://www.example.com/?test%20Query%20Param=test%20%25va%2Fue")
   request is obtained from
   1) variable builder through slicing path.
58. Google.Apis.Tests.Apis.Requests.RequestBuilderTest.TestMultipleQueryParameters
Code with line numbers
public TestMultipleQueryParameters(){(line 128)
var builder = new RequestBuilder();(line 131)
builder.AddParameter(RequestParameterType.Query,"q","value1");(line 136)
builder.AddParameter(RequestParameterType.Query,"q","value2");(line 137)
var request = builder.CreateRequest();(line 139)
Assert.That(request.RequestUri,Is.EqualTo(new Uri("http://www.example.com/?q=value1&q=value2")));(line 140)
}
This unit test case method tests multiple query parameters .
This unit test case includes following focal methods:
(1) var request = builder.CreateRequest();(@line 139)
This focal method is related to assertions at line 140
This unit test case validates that:
(1) request.RequestUri is equal to new Uri("http://www.example.com/?q=value1&q=value2")
   request is obtained from
   1) variable builder through slicing path.
59. Google.Apis.Tests.Apis.Requests.RequestBuilderTest.TestNullQueryParameters
Code with line numbers
public TestNullQueryParameters(){(line 144)
var builder = new RequestBuilder();(line 147)
builder.AddParameter(RequestParameterType.Query,"q",null);(line 153)
builder.AddParameter(RequestParameterType.Query,"p",String.Empty);(line 154)
Assert.That(builder.BuildUri().AbsoluteUri,Is.EqualTo("http://www.example.com/?p"));(line 156)
}
This unit test case method tests null query parameters .
This unit test case includes following focal methods:
(1) An assertion in line 156 validating that builder.BuildUri().AbsoluteUri is equal to "http://www.example.com/?p"
60. Google.Apis.Tests.Apis.Requests.RequestBuilderTest.TestPathParameter
Code with line numbers
public TestPathParameter(){(line 160)
var builder = new RequestBuilder();(line 163)
builder.AddParameter(RequestParameterType.Path,"id","value");(line 169)
var request = builder.CreateRequest();(line 171)
Assert.That(request.RequestUri,Is.EqualTo(new Uri("http://www.example.com/test/value/foo/bar")));(line 172)
}
This unit test case method tests path parameter .
This unit test case includes following focal methods:
(1) var request = builder.CreateRequest();(@line 171)
This focal method is related to assertions at line 172
This unit test case validates that:
(1) request.RequestUri is equal to new Uri("http://www.example.com/test/value/foo/bar")
   request is obtained from
   1) variable builder through slicing path.
61. Google.Apis.Tests.Apis.Requests.RequestBuilderTest.TestInvalidPathParameters
Code with line numbers
public TestInvalidPathParameters(){(line 176)
var builder = new RequestBuilder();(line 180)
Assert.Throws<ArgumentException>();(line 185)
builder = new RequestBuilder();(line 191)
builder.AddParameter(RequestParameterType.Path,"id","hello");(line 196)
Assert.Throws<ArgumentException>();(line 197)
}
This unit test case method tests invalid path parameters .
This unit test case validates that:
(1) The unit test throws an ArgumentException exception.
(2) The unit test throws an ArgumentException exception.
62. Google.Apis.Tests.Apis.Requests.RequestBuilderTest.TestPathParameterWithUrlEncode
Code with line numbers
public TestPathParameterWithUrlEncode(){(line 204)
var builder = new RequestBuilder();(line 207)
builder.AddParameter(RequestParameterType.Path,"id"," %va/ue");(line 213)
var request = builder.CreateRequest();(line 215)
Assert.That(request.RequestUri,Is.EqualTo(new Uri("http://www.example.com/test/%20%25va%2Fue")));(line 216)
}
This unit test case method tests path parameter with url encode.
This unit test case includes following focal methods:
(1) var request = builder.CreateRequest();(@line 215)
This focal method is related to assertions at line 216
This unit test case validates that:
(1) request.RequestUri is equal to new Uri("http://www.example.com/test/%20%25va%2Fue")
   request is obtained from
   1) variable builder through slicing path.
63. Google.Apis.Tests.Apis.Requests.RequestBuilderTest.TestQueryAndPathParameters
Code with line numbers
public TestQueryAndPathParameters(){(line 220)
var builder = new RequestBuilder();(line 223)
builder.AddParameter(RequestParameterType.Path,"list","red");(line 229)
builder.AddParameter(RequestParameterType.Path,"list","yellow");(line 230)
builder.AddParameter(RequestParameterType.Query,"on","1");(line 231)
Assert.That(builder.BuildUri().AbsoluteUri,Is.EqualTo("http://www.test.com/colors?list=red,yellow&on=1"));(line 233)
}
This unit test case method tests query and path parameters .
This unit test case includes following focal methods:
(1) An assertion in line 233 validating that builder.BuildUri().AbsoluteUri is equal to "http://www.test.com/colors?list=red,yellow&on=1"
64. Google.Apis.Tests.Apis.Requests.RequestBuilderTest.TestPathParameters_Level1
Code with line numbers
public TestPathParameters_Level1(){(line 238)
IDictionary<string,IEnumerable<string>> vars = new Dictionary();(line 241)
vars["var"] = new List;(line 242)
vars["hello"] = new List;(line 243)
SubtestPathParameters(vars,"{var}","value");(line 245)
SubtestPathParameters(vars,"{hello}","Hello%20World%21");(line 246)
}
This unit test case method tests path parameters level 1 .
65. Google.Apis.Tests.Apis.Requests.RequestBuilderTest.TestPathParameters_Level2
Code with line numbers
public TestPathParameters_Level2(){(line 250)
IDictionary<string,IEnumerable<string>> vars = new Dictionary();(line 253)
vars["var"] = new List;(line 254)
vars["hello"] = new List;(line 255)
vars["path"] = new List;(line 256)
SubtestPathParameters(vars,"{+var}","value");(line 258)
SubtestPathParameters(vars,"{+hello}","Hello%20World!");(line 259)
SubtestPathParameters(vars,"{+path}/here","foo/bar/here");(line 260)
SubtestPathParameters(vars,"here?ref={+path}","here?ref=/foo/bar");(line 261)
}
This unit test case method tests path parameters level 2 .
66. Google.Apis.Tests.Apis.Requests.RequestBuilderTest.TestPathParameters_Level3
Code with line numbers
public TestPathParameters_Level3(){(line 265)
IDictionary<string,IEnumerable<string>> vars = new Dictionary();(line 268)
vars["var"] = new List;(line 269)
vars["hello"] = new List;(line 270)
vars["empty"] = new List;(line 271)
vars["path"] = new List;(line 273)
vars["x"] = new List;(line 274)
vars["y"] = new List;(line 275)
SubtestPathParameters(vars,"map?{x,y}","map?1024,768");(line 277)
SubtestPathParameters(vars,"{x,hello,y}","1024,Hello%20World%21,768");(line 278)
SubtestPathParameters(vars,"{+x,hello,y}","1024,Hello%20World!,768");(line 279)
SubtestPathParameters(vars,"{+path,x}/here","foo/bar,1024/here");(line 280)
SubtestPathParameters(vars,"{#x,hello,y}","#1024,Hello%20World!,768");(line 281)
SubtestPathParameters(vars,"{#path,x}/here","#/foo/bar,1024/here");(line 282)
SubtestPathParameters(vars,"X{.var}","X.value");(line 283)
SubtestPathParameters(vars,"X{.x,y}","X.1024.768");(line 284)
SubtestPathParameters(vars,"{/var}","value");(line 285)
SubtestPathParameters(vars,"{/var,x}/here","value/1024/here");(line 286)
SubtestPathParameters(vars,"{;x,y}",";x=1024;y=768");(line 287)
SubtestPathParameters(vars,"{;x,y,empty}",";x=1024;y=768;empty");(line 288)
SubtestPathParameters(vars,"{?x,y}","?x=1024&y=768");(line 289)
SubtestPathParameters(vars,"{?x,y,empty}","?x=1024&y=768&empty=");(line 290)
SubtestPathParameters(vars,"?fixed=yes{&x}","?fixed=yes&x=1024");(line 291)
SubtestPathParameters(vars,"{&x,y,empty}","&x=1024&y=768&empty=");(line 292)
}
This unit test case method tests path parameters level 3 .
67. Google.Apis.Tests.Apis.Requests.RequestBuilderTest.TestPathParameters_Level4
Code with line numbers
public TestPathParameters_Level4(){(line 296)
IDictionary<string,IEnumerable<string>> vars = new Dictionary();(line 299)
vars["var"] = new List;(line 300)
vars["hello"] = new List;(line 301)
vars["path"] = new List;(line 302)
vars["list"] = new List;(line 303)
SubtestPathParameters(vars,"{var:3}","val");(line 305)
SubtestPathParameters(vars,"{var:30}","value");(line 306)
SubtestPathParameters(vars,"{list}","red,green,blue");(line 307)
SubtestPathParameters(vars,"{list*}","red,green,blue");(line 308)
SubtestPathParameters(vars,"{+path:6}/here","foo/b/here");(line 309)
SubtestPathParameters(vars,"{+list}","red,green,blue");(line 310)
SubtestPathParameters(vars,"{+list*}","red,green,blue");(line 311)
SubtestPathParameters(vars,"{#path:6}/here","#/foo/b/here");(line 312)
SubtestPathParameters(vars,"{#list}","#red,green,blue");(line 313)
SubtestPathParameters(vars,"{#list*}","#red,green,blue");(line 314)
SubtestPathParameters(vars,"X{.var:3}","X.val");(line 315)
SubtestPathParameters(vars,"X{.list}","X.red,green,blue");(line 316)
SubtestPathParameters(vars,"X{.list*}","X.red.green.blue");(line 317)
SubtestPathParameters(vars,"{/var:1,var}","v/value");(line 318)
SubtestPathParameters(vars,"{/list}","red,green,blue");(line 319)
SubtestPathParameters(vars,"{/list*}","red/green/blue");(line 320)
SubtestPathParameters(vars,"{/list*,path:4}","red/green/blue/%2Ffoo");(line 321)
SubtestPathParameters(vars,"{;hello:5}",";hello=Hello");(line 322)
SubtestPathParameters(vars,"{;list}",";list=red,green,blue");(line 323)
SubtestPathParameters(vars,"{;list*}",";list=red;list=green;list=blue");(line 324)
SubtestPathParameters(vars,"{?var:3}","?var=val");(line 325)
SubtestPathParameters(vars,"{?list}","?list=red,green,blue");(line 326)
SubtestPathParameters(vars,"{?list*}","?list=red&list=green&list=blue");(line 327)
SubtestPathParameters(vars,"{&var:3}","&var=val");(line 328)
SubtestPathParameters(vars,"{&list}","&list=red,green,blue");(line 329)
SubtestPathParameters(vars,"{&list*}","&list=red&list=green&list=blue");(line 330)
}
This unit test case method tests path parameters level 4 .
68. Google.Apis.Tests.Apis.Http.ConfigurableMessageHandlerTest.SendAsync_Redirect
Code with line numbers
public SendAsync_Redirect(){(line 115)
var location = "https://google.com";(line 118)
var redirectHandler = new RedirectMessageHandler(location);(line 119)
var configurableHanlder = new ConfigurableMessageHandler(redirectHandler);(line 120)
using()(line 125)
var request = new HttpRequestMessage(HttpMethod.Get,location);(line 127)
request.Headers.IfModifiedSince = new DateTimeOffset(DateTime.Now);(line 128)
request.Headers.IfUnmodifiedSince = new DateTimeOffset(DateTime.Now);(line 129)
request.Headers.IfMatch.Add(new EntityTagHeaderValue("\"a\""));(line 130)
request.Headers.IfNoneMatch.Add(new EntityTagHeaderValue("\"b\""));(line 131)
HttpResponseMessage response = client.SendAsync(request).Result;(line 133)
Assert.That(response.StatusCode,Is.EqualTo(HttpStatusCode.Redirect));(line 135)
Assert.That(response.Headers.Location,Is.EqualTo(new Uri(location + configurableHanlder.NumRedirects + 1)));(line 136)
Assert.That(redirectHandler.Calls,Is.EqualTo(configurableHanlder.NumRedirects + 1));(line 138)
}
This unit test case method tests send async redirect .
This unit test case validates that:
(1) response.StatusCode is equal to HttpStatusCode.Redirect
(2) response.Headers.Location is equal to new Uri(location + configurableHanlder.NumRedirects + 1)
(3) redirectHandler.Calls is equal to configurableHanlder.NumRedirects + 1
   redirectHandler is obtained from
   1) variable location through slicing path.
69. Google.Apis.Tests.Apis.Http.ConfigurableMessageHandlerTest.SendAsync_Redirect_FollowRedirectFalse
Code with line numbers
public SendAsync_Redirect_FollowRedirectFalse(){(line 145)
int tries = 12;(line 148)
var location = "https://google.com";(line 149)
var redirectHandler = new RedirectMessageHandler(location);(line 150)
var configurableHanlder = new ConfigurableMessageHandler(redirectHandler);(line 151)
using()(line 157)
var request = new HttpRequestMessage(HttpMethod.Get,location);(line 159)
request.Headers.IfModifiedSince = new DateTimeOffset(DateTime.Now);(line 160)
request.Headers.IfUnmodifiedSince = new DateTimeOffset(DateTime.Now);(line 161)
request.Headers.IfMatch.Add(new EntityTagHeaderValue("\"a\""));(line 162)
request.Headers.IfNoneMatch.Add(new EntityTagHeaderValue("\"b\""));(line 163)
HttpResponseMessage response = client.SendAsync(request).Result;(line 165)
Assert.That(response.StatusCode,Is.EqualTo(HttpStatusCode.Redirect));(line 168)
Assert.That(response.Headers.Location,Is.EqualTo(new Uri(location + 1)));(line 169)
Assert.That(redirectHandler.Calls,Is.EqualTo(1));(line 170)
}
This unit test case method tests send async redirect follow redirect false .
This unit test case validates that:
(1) response.StatusCode is equal to HttpStatusCode.Redirect
(2) response.Headers.Location is equal to new Uri(location + 1)
(3) redirectHandler.Calls is equal to 1
   redirectHandler is obtained from
   1) variable location through slicing path.
70. Google.Apis.Tests.Apis.Http.ConfigurableMessageHandlerTest.SendAsync_ExecuteInterceptor
Code with line numbers
public SendAsync_ExecuteInterceptor(){(line 214)
SubtestSendAsyncExecuteInterceptor(HttpStatusCode.OK);(line 217)
}
This unit test case method tests send async execute interceptor .
71. Google.Apis.Tests.Apis.Http.ConfigurableMessageHandlerTest.SendAsync_ExecuteInterceptor_AbnormalResponse
Code with line numbers
public SendAsync_ExecuteInterceptor_AbnormalResponse(){(line 224)
SubtestSendAsyncExecuteInterceptor(HttpStatusCode.BadRequest);(line 227)
}
This unit test case method tests send async execute interceptor abnormal response .
72. Google.Apis.Tests.Apis.Http.ConfigurableMessageHandlerTest.SendAsync_ExecuteInterceptor_AbnormalResponse_UnsuccessfulResponseHandler
Code with line numbers
public SendAsync_ExecuteInterceptor_AbnormalResponse_UnsuccessfulResponseHandler(){(line 257)
var handler = new InterceptorMessageHandler();(line 260)
handler.InjectedResponseMessage = new HttpResponseMessage();(line 261)
var configurableHanlder = new ConfigurableMessageHandler(handler);(line 266)
var interceptor = new InterceptorMessageHandler.Interceptor();(line 267)
configurableHanlder.ExecuteInterceptors.Add(interceptor);(line 268)
configurableHanlder.UnsuccessfulResponseHandlers.Add(new TrueUnsuccessfulResponseHandler());(line 269)
using()(line 271)
var request = new HttpRequestMessage(HttpMethod.Get,"https://test-execute-interceptor");(line 273)
HttpResponseMessage response = client.SendAsync(request).Result;(line 275)
Assert.That(interceptor.Calls,Is.EqualTo(configurableHanlder.NumTries));(line 276)
Assert.That(handler.Calls,Is.EqualTo(configurableHanlder.NumTries));(line 277)
}
This unit test case method tests send async execute interceptor abnormal response unsuccessful response handler .
This unit test case validates that:
(1) interceptor.Calls is equal to configurableHanlder.NumTries
(2) handler.Calls is equal to configurableHanlder.NumTries
   handler is obtained from
   1) variable handler through slicing path.
73. Google.Apis.Tests.Apis.Http.ConfigurableMessageHandlerTest.SendAsync_UnsuccessfulReponseHanlder_SuccessfulReponse
Code with line numbers
public SendAsync_UnsuccessfulReponseHanlder_SuccessfulReponse(){(line 362)
SubtestSendAsyncUnsuccessfulReponseHanlder(HttpStatusCode.OK);(line 365)
}
This unit test case method tests send async unsuccessful reponse hanlder successful reponse .
74. Google.Apis.Tests.Apis.Http.ConfigurableMessageHandlerTest.SendAsync_UnsuccessfulReponseHanlder_AbnormalResponse_DifferentStatusCode
Code with line numbers
public SendAsync_UnsuccessfulReponseHanlder_AbnormalResponse_DifferentStatusCode(){(line 372)
SubtestSendAsyncUnsuccessfulReponseHanlder(HttpStatusCode.BadGateway);(line 375)
}
This unit test case method tests send async unsuccessful reponse hanlder abnormal response different status code .
75. Google.Apis.Tests.Apis.Http.ConfigurableMessageHandlerTest.SendAsync_UnsuccessfulReponseHanlder_AbnormalResponse_SameStatusCode
Code with line numbers
public SendAsync_UnsuccessfulReponseHanlder_AbnormalResponse_SameStatusCode(){(line 382)
SubtestSendAsyncUnsuccessfulReponseHanlder(HttpStatusCode.ServiceUnavailable);(line 385)
}
This unit test case method tests send async unsuccessful reponse hanlder abnormal response same status code .
76. Google.Apis.Tests.Apis.Http.ConfigurableMessageHandlerTest.SendAsync_AbnormalResponse_WithoutUnsuccessfulReponseHandler
Code with line numbers
public SendAsync_AbnormalResponse_WithoutUnsuccessfulReponseHandler(){(line 389)
var handler = new UnsuccessfulResponseMessageHandler;(line 392)
var configurableHanlder = new ConfigurableMessageHandler(handler);(line 397)
using()(line 398)
var request = new HttpRequestMessage(HttpMethod.Get,"https://test-unsuccessful-handler");(line 400)
HttpResponseMessage response = client.SendAsync(request).Result;(line 402)
Assert.That(response.StatusCode,Is.EqualTo(HttpStatusCode.ServiceUnavailable));(line 403)
Assert.That(handler.Calls,Is.EqualTo(1));(line 404)
}
This unit test case method tests send async abnormal response without unsuccessful reponse handler.
This unit test case validates that:
(1) response.StatusCode is equal to HttpStatusCode.ServiceUnavailable
(2) handler.Calls is equal to 1
   handler is obtained from
   1) variable handler through slicing path.
77. Google.Apis.Tests.Apis.Http.ConfigurableMessageHandlerTest.SendAsync_ExceptionHandler_SuccessReponse
Code with line numbers
public SendAsync_ExceptionHandler_SuccessReponse(){(line 510)
SubtestSendAsyncExceptionHandler(false,true);(line 513)
}
This unit test case method tests send async exception handler success reponse .
78. Google.Apis.Tests.Apis.Http.ConfigurableMessageHandlerTest.SendAsync_ExceptionHandler_ThrowException_DontHandle
Code with line numbers
public SendAsync_ExceptionHandler_ThrowException_DontHandle(){(line 520)
SubtestSendAsyncExceptionHandler(true,false);(line 523)
}
This unit test case method tests send async exception handler throw exception dont handle .
79. Google.Apis.Tests.Apis.Http.ConfigurableMessageHandlerTest.SendAsync_ExceptionHandler_ThrowException_Handle
Code with line numbers
public SendAsync_ExceptionHandler_ThrowException_Handle(){(line 530)
SubtestSendAsyncExceptionHandler(true,true);(line 533)
}
This unit test case method tests send async exception handler throw exception handle .
80. Google.Apis.Tests.Apis.Http.ConfigurableMessageHandlerTest.SendAsync_ThrowException_WithoutExceptionHandler
Code with line numbers
public SendAsync_ThrowException_WithoutExceptionHandler(){(line 537)
var handler = new ExceptionMessageHandler;(line 540)
var configurableHanlder = new ConfigurableMessageHandler(handler);(line 542)
using()(line 544)
var request = new HttpRequestMessage(HttpMethod.Get,"https://test-exception-handler");(line 546)
try(line 547)
HttpResponseMessage response = client.SendAsync(request).Result;(line 549)
Assert.Fail("SendAsync should throw an exception");(line 550)
catch(AggregateException ae)(line 552)
Assert.That(ae.InnerException.Message,Is.EqualTo(ExceptionMessageHandler.ExceptionMessage));(line 554)
catch(Exception )(line 556)
Assert.Fail("AggregateException was suppose to be thrown");(line 558)
Assert.That(handler.Calls,Is.EqualTo(1));(line 560)
}
This unit test case method tests send async throw exception without exception handler.
This unit test case validates that:
(1) Fail at line 550 and "SendAsync should throw an exception".
(2) ae.InnerException.Message is equal to ExceptionMessageHandler.ExceptionMessage
(3) Fail at line 558 and "AggregateException was suppose to be thrown".
(4) handler.Calls is equal to 1
   handler is obtained from
   1) variable handler through slicing path.
81. Google.Apis.Tests.Apis.Http.ConfigurableMessageHandlerTest.SendAsync_BackOffExceptionHandler_Throw_Max2Minutes
Code with line numbers
public SendAsync_BackOffExceptionHandler_Throw_Max2Minutes(){(line 574)
var initializer = new BackOffHandler.Initializer(new ExponentialBackOff(TimeSpan.Zero));(line 578)
SubtestSendAsync_BackOffExceptionHandler(true,initializer);(line 579)
}
This unit test case method tests send async back off exception handler throw max 2 minutes .
82. Google.Apis.Tests.Apis.Http.ConfigurableMessageHandlerTest.SendAsync_BackOffExceptionHandler_Throw_Max200Milliseconds
Code with line numbers
public SendAsync_BackOffExceptionHandler_Throw_Max200Milliseconds(){(line 586)
var initializer = new BackOffHandler.Initializer(new ExponentialBackOff(TimeSpan.Zero));(line 589)
SubtestSendAsync_BackOffExceptionHandler(true,initializer);(line 593)
}
This unit test case method tests send async back off exception handler throw max 200 milliseconds .
83. Google.Apis.Tests.Apis.Http.ConfigurableMessageHandlerTest.SendAsync_BackOffExceptionHandler_Throw_Max1Hour
Code with line numbers
public SendAsync_BackOffExceptionHandler_Throw_Max1Hour(){(line 600)
var initializer = new BackOffHandler.Initializer(new ExponentialBackOff(TimeSpan.Zero));(line 603)
SubtestSendAsync_BackOffExceptionHandler(true,initializer);(line 607)
}
This unit test case method tests send async back off exception handler throw max 1 hour .
84. Google.Apis.Tests.Apis.Http.ConfigurableMessageHandlerTest.SendAsync_BackOffExceptionHandler_ThrowCanceledException
Code with line numbers
public SendAsync_BackOffExceptionHandler_ThrowCanceledException(){(line 614)
var initializer = new BackOffHandler.Initializer(new ExponentialBackOff(TimeSpan.Zero));(line 617)
SubtestSendAsync_BackOffExceptionHandler(true,initializer,new TaskCanceledException());(line 618)
}
This unit test case method tests send async back off exception handler throw canceled exception .
85. Google.Apis.Tests.Apis.Http.ConfigurableMessageHandlerTest.SendAsync_BackOffExceptionHandler_DifferentHandler
Code with line numbers
public SendAsync_BackOffExceptionHandler_DifferentHandler(){(line 624)
var initializer = new BackOffHandler.Initializer(new ExponentialBackOff(TimeSpan.Zero));(line 627)
initializer.HandleExceptionFunc =;(line 628)
SubtestSendAsync_BackOffExceptionHandler(true,initializer,new InvalidCastException());(line 629)
initializer.HandleExceptionFunc =;(line 631)
SubtestSendAsync_BackOffExceptionHandler(true,initializer,new InvalidCastException());(line 632)
}
This unit test case method tests send async back off exception handler different handler .
86. Google.Apis.Tests.Apis.Http.ConfigurableMessageHandlerTest.SendAsync_BackOffExceptionHandler_DontThrow
Code with line numbers
public SendAsync_BackOffExceptionHandler_DontThrow(){(line 636)
var initializer = new BackOffHandler.Initializer(new ExponentialBackOff(TimeSpan.Zero));(line 639)
SubtestSendAsync_BackOffExceptionHandler(false,initializer);(line 640)
}
This unit test case method tests send async back off exception handler dont throw .
87. Google.Apis.Tests.Apis.Http.ConfigurableMessageHandlerTest.SendAsync_BackOffUnsuccessfulResponseHandler_ServiceUnavailable_Max5Seconds
Code with line numbers
public SendAsync_BackOffUnsuccessfulResponseHandler_ServiceUnavailable_Max5Seconds(){(line 702)
var initializer = new BackOffHandler.Initializer(new ExponentialBackOff(TimeSpan.Zero));(line 705)
SubtestSendAsync_BackOffUnsuccessfulResponseHandler(HttpStatusCode.ServiceUnavailable,initializer);(line 709)
}
This unit test case method tests send async back off unsuccessful response handler service unavailable max 5 seconds .
88. Google.Apis.Tests.Apis.Http.ConfigurableMessageHandlerTest.SendAsync_BackOffUnsuccessfulResponseHandler_ServiceUnavailable_Max10Hours
Code with line numbers
public SendAsync_BackOffUnsuccessfulResponseHandler_ServiceUnavailable_Max10Hours(){(line 716)
var initializer = new BackOffHandler.Initializer(new ExponentialBackOff(TimeSpan.Zero));(line 719)
SubtestSendAsync_BackOffUnsuccessfulResponseHandler(HttpStatusCode.ServiceUnavailable,initializer);(line 723)
}
This unit test case method tests send async back off unsuccessful response handler service unavailable max 10 hours .
89. Google.Apis.Tests.Apis.Http.ConfigurableMessageHandlerTest.SendAsync_BackOffUnsuccessfulResponseHandler_OK
Code with line numbers
public SendAsync_BackOffUnsuccessfulResponseHandler_OK(){(line 729)
var initializer = new BackOffHandler.Initializer(new ExponentialBackOff(TimeSpan.Zero));(line 732)
SubtestSendAsync_BackOffUnsuccessfulResponseHandler(HttpStatusCode.OK,initializer);(line 733)
}
This unit test case method tests send async back off unsuccessful response handler ok .
90. Google.Apis.Tests.Apis.Http.ConfigurableMessageHandlerTest.SendAsync_BackOffUnsuccessfulResponseHandler_Cancel
Code with line numbers
public SendAsync_BackOffUnsuccessfulResponseHandler_Cancel(){(line 737)
var initializer = new BackOffHandler.Initializer(new ExponentialBackOff(TimeSpan.Zero));(line 741)
SubtestSendAsync_BackOffUnsuccessfulResponseHandler(HttpStatusCode.ServiceUnavailable,initializer,2);(line 745)
SubtestSendAsync_BackOffUnsuccessfulResponseHandler(HttpStatusCode.ServiceUnavailable,initializer,6);(line 746)
}
This unit test case method tests send async back off unsuccessful response handler cancel .
91. Google.Apis.Tests.Apis.Http.MaxUrlLengthInterceptorTest.TestGetWithUrlOkayLengthByDefault
Code with line numbers
public TestGetWithUrlOkayLengthByDefault(){(line 45)
SubtestGetWithUrlOkayLengthByDefault(DefaultMaxUrlLength,HttpMethod.Get);(line 48)
SubtestGetWithUrlOkayLengthByDefault(DefaultMaxUrlLength - 1,HttpMethod.Get);(line 49)
SubtestGetWithUrlOkayLengthByDefault(100,HttpMethod.Get);(line 50)
}
This unit test case method tests get with url okay length by default.
92. Google.Apis.Tests.Apis.Http.MaxUrlLengthInterceptorTest.TestNonGetWithUrlOkayLengthByDefault
Code with line numbers
public TestNonGetWithUrlOkayLengthByDefault(){(line 57)
SubtestGetWithUrlOkayLengthByDefault(DefaultMaxUrlLength + 1,HttpMethod.Post);(line 60)
SubtestGetWithUrlOkayLengthByDefault(DefaultMaxUrlLength,HttpMethod.Post);(line 61)
SubtestGetWithUrlOkayLengthByDefault(DefaultMaxUrlLength - 1,HttpMethod.Post);(line 62)
SubtestGetWithUrlOkayLengthByDefault(DefaultMaxUrlLength + 1,HttpMethod.Delete);(line 63)
SubtestGetWithUrlOkayLengthByDefault(DefaultMaxUrlLength,HttpMethod.Delete);(line 64)
SubtestGetWithUrlOkayLengthByDefault(DefaultMaxUrlLength - 1,HttpMethod.Delete);(line 65)
}
This unit test case method tests non get with url okay length by default.
93. Google.Apis.Tests.Apis.Http.MaxUrlLengthInterceptorTest.TestGetPathQueryWithUrlOkayLengthByDefault
Code with line numbers
public TestGetPathQueryWithUrlOkayLengthByDefault(){(line 98)
uint maxUrlLength = 1000;(line 101)
var query = "q=" + new String('x',1000);(line 102)
var uri = "http://www.googleapis.com/language/translate/v2";(line 103)
var requestUri = uri + "?" + query;(line 104)
var request = new HttpRequestMessage(HttpMethod.Get,requestUri);(line 105)
var mockHandler = new MockMessageHandler();(line 106)
var handler = new ConfigurableMessageHandler(mockHandler);(line 107)
handler.ExecuteInterceptors.Add(new MaxUrlLengthInterceptor(maxUrlLength));(line 108)
using()(line 109)
httpClient.SendAsync(request);(line 111)
Assert.That(request.RequestUri,Is.EqualTo(new Uri(uri)));(line 113)
Assert.That(mockHandler.RequestContent,Is.EqualTo(query));(line 114)
}
This unit test case method tests get path query with url okay length by default.
This unit test case validates that:
(1) request.RequestUri is equal to new Uri(uri)
   request is obtained from
   1) variable uri through slicing path
   2) variable query through slicing path.
(2) mockHandler.RequestContent is equal to query
   mockHandler is obtained from
   1) variable mockHandler through slicing path.
94. Google.Apis.Tests.Apis.Http.MaxUrlLengthInterceptorTest.TestGetWithUrlTooLongByUserSpecified
Code with line numbers
public TestGetWithUrlTooLongByUserSpecified(){(line 122)
uint maxUrlLength = 1000;(line 125)
var query = "q=" + new String('x',900) + "&x=" + new String('y',72);(line 126)
var uri = "http://www.example.com/";(line 127)
var requestUri = uri + "?" + query;(line 128)
var request = new HttpRequestMessage(HttpMethod.Get,requestUri);(line 129)
var mockHandler = new MockMessageHandler();(line 130)
var handler = new ConfigurableMessageHandler(mockHandler);(line 131)
handler.ExecuteInterceptors.Add(new MaxUrlLengthInterceptor(maxUrlLength));(line 132)
using()(line 133)
httpClient.SendAsync(request);(line 135)
Assert.That(requestUri.Length,Is.EqualTo(maxUrlLength + 1));(line 137)
Assert.That(request.Method,Is.EqualTo(HttpMethod.Post));(line 139)
Assert.That(request.Headers.GetValues("X-HTTP-Method-Override").Single(),Is.EqualTo("GET"));(line 140)
Assert.That(request.Content.Headers.ContentType,Is.EqualTo(new MediaTypeHeaderValue("application/x-www-form-urlencoded")));(line 141)
Assert.That(request.RequestUri,Is.EqualTo(new Uri(uri)));(line 143)
Assert.That(mockHandler.RequestContent,Is.EqualTo(query));(line 144)
}
This unit test case method tests get with url too long by user specified.
This unit test case validates that:
(1) requestUri.Length is equal to maxUrlLength + 1
   requestUri is obtained from
   1) variable uri through slicing path
   2) variable query through slicing path.
(2) request.Method is equal to HttpMethod.Post
   request is obtained from
   1) variable uri through slicing path
   2) variable query through slicing path.
(3) request.Headers.GetValues("X-HTTP-Method-Override").Single() is equal to "GET"
   request is obtained from
   1) variable uri through slicing path
   2) variable query through slicing path.
(4) request.Content.Headers.ContentType is equal to new MediaTypeHeaderValue("application/x-www-form-urlencoded")
   request is obtained from
   1) variable uri through slicing path
   2) variable query through slicing path.
(5) request.RequestUri is equal to new Uri(uri)
   request is obtained from
   1) variable uri through slicing path
   2) variable query through slicing path.
(6) mockHandler.RequestContent is equal to query
   mockHandler is obtained from
   1) variable mockHandler through slicing path.
95. Google.Apis.Tests.Apis.Utils.ExponentialBackOffTest.GetNextBackOff_InvalidValue
Code with line numbers
public GetNextBackOff_InvalidValue(){(line 33)
ExponentialBackOff backOff = new ExponentialBackOff();(line 36)
try(line 37)
backOff.GetNextBackOff(0);(line 39)
Assert.Fail();(line 40)
catch(ArgumentOutOfRangeException )(line 42)
try(line 44)
backOff.GetNextBackOff(- 2);(line 46)
Assert.Fail();(line 47)
catch(ArgumentOutOfRangeException )(line 49)
}
This unit test case method tests get next back off invalid value .
This unit test case validates that:
(1) Fail at line 40.
(2) Fail at line 47.
96. Google.Apis.Tests.Apis.Utils.ExponentialBackOffTest.Constructor_InvalidValue
Code with line numbers
public Constructor_InvalidValue(){(line 53)
SubtestConstructor_InvalidValue(TimeSpan.FromMilliseconds(- 1));(line 57)
SubtestConstructor_InvalidValue(TimeSpan.FromDays(- 1));(line 58)
SubtestConstructor_InvalidValue(TimeSpan.FromMilliseconds(1001));(line 59)
SubtestConstructor_InvalidValue(TimeSpan.FromMilliseconds(500),- 1);(line 61)
SubtestConstructor_InvalidValue(TimeSpan.FromMilliseconds(500),21);(line 62)
}
This unit test case method tests handle constructor invalid value .
97. Google.Apis.Tests.Apis.Utils.ExponentialBackOffTest.GetNextBackOff_Retry1To15
Code with line numbers
public GetNextBackOff_Retry1To15(){(line 78)
foreach(int i)(line 81)
SubtestGetNextBackOff(i);(line 83)
SubtestGetNextBackOff(i,TimeSpan.FromMilliseconds(20));(line 84)
SubtestGetNextBackOff(i,TimeSpan.FromMilliseconds(0),0);(line 85)
}
This unit test case method tests get next back off retry 1 to 15.
98. Google.Apis.Tests.Apis.Utils.ExponentialBackOffTest.GetNextBackOff_MaxNumRetries
Code with line numbers
public GetNextBackOff_MaxNumRetries(){(line 117)
SubtestGetNextBackOff_MaxNumRetries(1);(line 120)
SubtestGetNextBackOff_MaxNumRetries(10);(line 121)
SubtestGetNextBackOff_MaxNumRetries(11);(line 122)
}
This unit test case method tests get next back off max num retries .
99. Google.Apis.Tests.Apis.Utils.RepeatableTest.CreateRepeatableTest
Code with line numbers
public CreateRepeatableTest(){(line 33)
Assert.IsNotNull(Repeatable "Test");(line 37)
Assert.IsNotNull(Repeatable new);(line 38)
Assert.IsNull(Repeatable new string);(line 39)
Assert.IsNotNull(Repeatable 0);(line 42)
Assert.IsNotNull(Repeatable 1);(line 43)
Assert.IsNotNull(Repeatable new);(line 44)
Assert.IsNull(Repeatable new int);(line 45)
Repeatable<int> repeatable = new;(line 48)
int i = 0;(line 49)
foreach(int value)(line 50)
Assert.AreEqual(++ i,value);(line 52)
Assert.AreEqual(9,i);(line 54)
}
This unit test case method tests create repeatable test .
This unit test case validates that:
(1) Repeatable "Test" is not null.
(2) Repeatable new is not null.
(3) Repeatable new string is null.
(4) Repeatable 0 is not null.
(5) Repeatable 1 is not null.
(6) Repeatable new is not null.
(7) Repeatable new int is null.
(8) value is equal to ++ i.
(9) i is equal to 9.
100. Google.Apis.Tests.Apis.Utils.RepeatableTest.TestImplicitConversion
Code with line numbers
public TestImplicitConversion(){(line 61)
Assert.AreEqual("Foo",ConcatStrings("Foo",null));(line 64)
Assert.AreEqual("Foobar",ConcatStrings("Foo","bar"));(line 65)
Assert.AreEqual("FoobarTest",ConcatStrings("Foo",new));(line 66)
}
This unit test case method tests implicit conversion .
This unit test case validates that:
(1) ConcatStrings("Foo",null) is equal to "Foo".
(2) ConcatStrings("Foo","bar") is equal to "Foobar".
(3) ConcatStrings("Foo",new) is equal to "FoobarTest".
101. Google.Apis.Tests.Apis.Utils.RepeatableTest.TestRepeatedGet
Code with line numbers
public TestRepeatedGet(){(line 72)
int testInput = new;(line 75)
Repeatable<int> repeatable = testInput;(line 76)
CollectionAssert.AreEqual(testInput,repeatable);(line 79)
CollectionAssert.AreEqual(testInput,repeatable);(line 82)
}
This unit test case method tests repeated get .
102. Google.Apis.Tests.Apis.Utils.RepeatableTest.TestModifiedSource
Code with line numbers
public TestModifiedSource(){(line 88)
int testInput = new;(line 91)
var testList = new List(testInput);(line 92)
Repeatable<int> repeatable = testList;(line 93)
CollectionAssert.AreEqual(testInput,repeatable);(line 96)
testList.RemoveAt(0);(line 99)
CollectionAssert.AreEqual(testInput,repeatable);(line 100)
}
This unit test case method tests modified source .
103. Google.Apis.Tests.Apis.Utils.StringValueAttributeTest.ConstructTest
Code with line numbers
public ConstructTest(){(line 32)
Assert.Throws<ArgumentNullException>();(line 36)
var attribute = new StringValueAttribute("FooBar");(line 39)
Assert.AreEqual("FooBar",attribute.Text);(line 40)
}
This unit test case method tests construct test .
This unit test case validates that:
(1) The unit test throws an ArgumentNullException exception.
(2) attribute.Text is equal to "FooBar".
104. Google.Apis.Tests.Apis.Download.MediaDownloaderTest.Download_MultipleChunks
Code with line numbers
public Download_MultipleChunks(){(line 111)
Subtest_Download_Chunks(2);(line 114)
Subtest_Download_Chunks(int StreamContent.Length - 1);(line 115)
}
This unit test case method tests download multiple chunks .
105. Google.Apis.Tests.Apis.Download.MediaDownloaderTest.Download_SingleChunk
Code with line numbers
public Download_SingleChunk(){(line 119)
Subtest_Download_Chunks(int StreamContent.Length);(line 122)
Subtest_Download_Chunks(int StreamContent.Length + 1);(line 123)
Subtest_Download_Chunks(100);(line 124)
}
This unit test case method tests download single chunk .
106. Google.Apis.Tests.Apis.Download.MediaDownloaderTest.Download_SingleChunk_UriContainsQueryParameters
Code with line numbers
public Download_SingleChunk_UriContainsQueryParameters(){(line 128)
Subtest_Download_Chunks(int StreamContent.Length,true,0,"https://www.sample.com?a=1&b=2");(line 131)
}
This unit test case method tests download single chunk uri contains query parameters .
107. Google.Apis.Tests.Apis.Download.MediaDownloaderTest.DownloadAsync_MultipleChunks
Code with line numbers
public DownloadAsync_MultipleChunks(){(line 137)
Subtest_Download_Chunks(2,false);(line 140)
Subtest_Download_Chunks(int StreamContent.Length - 1,false);(line 141)
}
This unit test case method tests download async multiple chunks .
108. Google.Apis.Tests.Apis.Download.MediaDownloaderTest.DownloadAsync_SingleChunk
Code with line numbers
public DownloadAsync_SingleChunk(){(line 147)
Subtest_Download_Chunks(int StreamContent.Length,false);(line 150)
Subtest_Download_Chunks(int StreamContent.Length + 1,false);(line 151)
Subtest_Download_Chunks(100,false);(line 152)
}
This unit test case method tests download async single chunk .
109. Google.Apis.Tests.Apis.Download.MediaDownloaderTest.DownloadAsync_Cancel
Code with line numbers
public DownloadAsync_Cancel(){(line 158)
Subtest_Download_Chunks(2,false,3);(line 161)
Subtest_Download_Chunks(int StreamContent.Length - 1,false,1);(line 162)
}
This unit test case method tests download async cancel .
110. Google.Apis.Tests.Apis.Logging.NullLoggerTests.ConstructTest
Code with line numbers
public ConstructTest(){(line 34)
Assert.DoesNotThrow();(line 37)
}
This unit test case method tests construct test .
This unit test case validates that:
(1) The unit test does not throw an exception.
111. Google.Apis.Tests.Apis.Logging.NullLoggerTests.GetTypeTest
Code with line numbers
public GetTypeTest(){(line 43)
var logger = new NullLogger();(line 46)
Assert.IsNotNull(logger.ForType<NullLoggerTests>());(line 47)
}
This unit test case method tests get type test .
This unit test case includes following focal methods:
(1) An assertion in line 47 validating that logger.ForType() is not null.
112. Google.Apis.Tests.Apis.Logging.NullLoggerTests.SimpleLogTest
Code with line numbers
public SimpleLogTest(){(line 53)
var myLogger = new NullLogger();(line 56)
myLogger.Debug("FooBar");(line 57)
myLogger.Warning("FooBar");(line 58)
myLogger.Error("FooBar");(line 59)
myLogger.Error(new Exception(),"FooBar");(line 60)
myLogger.Info("FooBar");(line 61)
myLogger.Info("FooBar","Bar");(line 62)
Assert.AreEqual(myLogger.IsDebugEnabled,myLogger.IsDebugEnabled);(line 63)
}
This unit test case method tests handle simple log test .
This unit test case includes following focal methods:
(1) myLogger.Info("FooBar","Bar");(@line 62)
This focal method is related to assertions at line 63
This unit test case validates that:
(1) myLogger.IsDebugEnabled is equal to myLogger.IsDebugEnabled.
113. Google.Apis.Tests.Apis.Util.UtilitiesTest.ThrowIfNullTest
Code with line numbers
public ThrowIfNullTest(){(line 30)
string str = null;(line 33)
Assert.Throws(typeof(ArgumentNullException),);(line 34)
str = "123";(line 35)
str.ThrowIfNull("Not throwen");(line 36)
}
This unit test case method tests throw if null test .
This unit test case validates that:
(1) The unit test throws an exception.
114. Google.Apis.Tests.GoogleApiExceptionTests.ConstructorTest
Code with line numbers
public ConstructorTest(){(line 32)
var name = "TestName_ConstructorTest";(line 35)
var exception = new GoogleApiException(name,"Test");(line 37)
Assert.IsInstanceOf<Exception>(exception);(line 38)
Assert.That(exception.ToString(),Contains.Substring(name));(line 39)
}
This unit test case method tests handle constructor test .
This unit test case includes following focal methods:
(1) An assertion in line 39 validating that exception.ToString() Contains.Substring(name
This unit test case validates that:
(1) exception is a instance of Exception.
   exception is obtained from
   1) variable name through slicing path.
115. Google.Apis.Tests.GoogleApiExceptionTests.ThrowTest
Code with line numbers
public ThrowTest(){(line 45)
Assert.Throws<GoogleApiException>();(line 48)
}
This unit test case method tests throw test .
This unit test case validates that:
(1) The unit test throws an GoogleApiException exception.
116. Google.Apis.Tests.GoogleApiExceptionTests.ConstructorFailTest
Code with line numbers
public ConstructorFailTest(){(line 54)
Assert.Throws<ArgumentNullException>();(line 57)
}
This unit test case method tests handle constructor fail test .
This unit test case validates that:
(1) The unit test throws an ArgumentNullException exception.
117. Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlowTests.TestConstructor_ArgumentException
Code with line numbers
public TestConstructor_ArgumentException(){(line 48)
try(line 52)
new AuthorizationCodeFlow(new AuthorizationCodeFlow.Initializer("https://authorization_code.com","https://token.com"));(line 54)
Assert.Fail();(line 56)
catch(ArgumentException ex)(line 58)
Assert.True(ex.Message.Contains("You MUST set ClientSecret or ClientSecretStream"));(line 60)
}
This unit test case method tests constructor argument exception .
This unit test case validates that:
(1) Fail at line 56.
(2) ex.Message.Contains("You MUST set ClientSecret or ClientSecretStream") is true.
118. Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlowTests.TestConstructor_DefaultValues
Code with line numbers
public TestConstructor_DefaultValues(){(line 64)
var flow = CreateFlow();(line 67)
Assert.NotNull(flow.AccessMethod);(line 68)
Assert.That(flow.AccessMethod,Is.InstanceOf<BearerToken.AuthorizationHeaderAccessMethod>());(line 69)
Assert.That(flow.AuthorizationServerUrl,Is.EqualTo("https://authorization.com"));(line 70)
Assert.NotNull(flow.ClientSecrets);(line 71)
Assert.That(flow.ClientSecrets.ClientId,Is.EqualTo("id"));(line 72)
Assert.That(flow.ClientSecrets.ClientSecret,Is.EqualTo("secret"));(line 73)
Assert.That(flow.Clock,Is.InstanceOf<SystemClock>());(line 74)
Assert.Null(flow.DataStore);(line 75)
Assert.NotNull(flow.HttpClient);(line 76)
Assert.NotNull(flow.Scopes);(line 77)
Assert.That(flow.TokenServerUrl,Is.EqualTo("https://token.com"));(line 78)
Assert.That(flow.HttpClient.MessageHandler.UnsuccessfulResponseHandlers.Count(),Is.EqualTo(1));(line 80)
Assert.That(flow.HttpClient.MessageHandler.UnsuccessfulResponseHandlers.First(),Is.InstanceOf<BackOffHandler>());(line 81)
}
This unit test case method tests constructor default values .
This unit test case validates that:
(1) flow.AccessMethod is not null.
(2) flow.AccessMethod Is.InstanceOf(
(3) flow.AuthorizationServerUrl is equal to "https://authorization.com"
(4) flow.ClientSecrets is not null.
(5) flow.ClientSecrets.ClientId is equal to "id"
(6) flow.ClientSecrets.ClientSecret is equal to "secret"
(7) flow.Clock Is.InstanceOf(
(8) flow.DataStore is null.
(9) flow.HttpClient is not null.
(10) flow.Scopes is not null.
(11) flow.TokenServerUrl is equal to "https://token.com"
(12) flow.HttpClient.MessageHandler.UnsuccessfulResponseHandlers.Count() is equal to 1
(13) flow.HttpClient.MessageHandler.UnsuccessfulResponseHandlers.First() Is.InstanceOf(
119. Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlowTests.LoadTokenAsync_NoDataStore
Code with line numbers
public LoadTokenAsync_NoDataStore(){(line 89)
var flow = CreateFlow();(line 92)
Assert.Null(flow.LoadTokenAsync("user",CancellationToken.None).Result);(line 93)
}
This unit test case method tests load token async no data store .
This unit test case includes following focal methods:
(1) An assertion in line 93 validating that flow.LoadTokenAsync("user",CancellationToken.None).Result is null.
120. Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlowTests.LoadTokenAsync_NullResponse
Code with line numbers
public LoadTokenAsync_NullResponse(){(line 96)
TaskCompletionSource<TokenResponse> tcs = new TaskCompletionSource();(line 99)
tcs.SetResult(null);(line 100)
Assert.Null(SubtestLoadTokenAsync(tcs));(line 101)
}
This unit test case method tests load token async null response .
This unit test case validates that:
(1) SubtestLoadTokenAsync(tcs) is null.
121. Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlowTests.LoadTokenAsync_TokenResponse
Code with line numbers
public LoadTokenAsync_TokenResponse(){(line 104)
TokenResponse response = new TokenResponse;(line 107)
TaskCompletionSource<TokenResponse> tcs = new TaskCompletionSource();(line 112)
tcs.SetResult(response);(line 113)
var result = SubtestLoadTokenAsync(tcs);(line 114)
Assert.That(result,Is.EqualTo(response));(line 115)
}
This unit test case method tests load token async token response .
This unit test case validates that:
(1) result is equal to response
   result is obtained from
   1) variable tcs through slicing path.
122. Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlowTests.TestCreateAuthorizationCodeRequest
Code with line numbers
public TestCreateAuthorizationCodeRequest(){(line 132)
var request = CreateFlow(scopes : new).CreateAuthorizationCodeRequest("redirect");(line 135)
Assert.That(request.AuthorizationServerUrl,Is.EqualTo(new Uri(AuthorizationCodeUrl)));(line 136)
Assert.That(request.ClientId,Is.EqualTo("id"));(line 137)
Assert.That(request.RedirectUri,Is.EqualTo("redirect"));(line 138)
Assert.That(request.ResponseType,Is.EqualTo("code"));(line 139)
Assert.That(request.Scope,Is.EqualTo("a b"));(line 140)
Assert.Null(request.State);(line 141)
}
This unit test case method tests create authorization code request .
This unit test case validates that:
(1) request.AuthorizationServerUrl is equal to new Uri(AuthorizationCodeUrl)
(2) request.ClientId is equal to "id"
(3) request.RedirectUri is equal to "redirect"
(4) request.ResponseType is equal to "code"
(5) request.Scope is equal to "a b"
(6) request.State is null.
123. Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlowTests.TestExchangeCodeForTokenAsync
Code with line numbers
public TestExchangeCodeForTokenAsync(){(line 146)
var mock = new Mock();(line 149)
var handler = new FetchTokenMessageHandler();(line 150)
handler.AuthorizationCodeTokenRequest = new AuthorizationCodeTokenRequest();(line 151)
MockHttpClientFactory mockFactory = new MockHttpClientFactory(handler);(line 157)
TaskCompletionSource<object> tcs = new TaskCompletionSource();(line 159)
tcs.SetResult(null);(line 160)
mock.Setup().Returns(tcs.Task);(line 161)
var flow = CreateFlow(httpClientFactory : mockFactory,scopes : new,dataStore : mock.Object);(line 163)
var response = flow.ExchangeCodeForTokenAsync("uSer","c0de","redIrect",CancellationToken.None).Result;(line 164)
SubtestTokenResponse(response);(line 165)
mock.Verify();(line 167)
}
This unit test case method tests exchange code for token async.
124. Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlowTests.TestRefreshTokenAsync
Code with line numbers
public TestRefreshTokenAsync(){(line 170)
var mock = new Mock();(line 173)
var handler = new FetchTokenMessageHandler();(line 174)
handler.RefreshTokenRequest = new RefreshTokenRequest();(line 175)
MockHttpClientFactory mockFactory = new MockHttpClientFactory(handler);(line 180)
TaskCompletionSource<object> tcs = new TaskCompletionSource();(line 182)
tcs.SetResult(null);(line 183)
mock.Setup().Returns(tcs.Task);(line 184)
var flow = CreateFlow(httpClientFactory : mockFactory,scopes : new,dataStore : mock.Object);(line 186)
var response = flow.RefreshTokenAsync("uSer","REFRESH",CancellationToken.None).Result;(line 187)
SubtestTokenResponse(response);(line 188)
mock.Verify();(line 191)
}
This unit test case method tests refresh token async .
125. Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlowTests.TestFetchTokenAsync_AuthorizationCodeRequest
Code with line numbers
public TestFetchTokenAsync_AuthorizationCodeRequest(){(line 302)
var handler = new FetchTokenMessageHandler();(line 305)
handler.AuthorizationCodeTokenRequest = new AuthorizationCodeTokenRequest();(line 306)
MockHttpClientFactory mockFactory = new MockHttpClientFactory(handler);(line 312)
var flow = CreateFlow(httpClientFactory : mockFactory);(line 314)
var response = flow.FetchTokenAsync("user",handler.AuthorizationCodeTokenRequest,CancellationToken.None).Result;(line 315)
SubtestTokenResponse(response);(line 317)
}
This unit test case method tests fetch token async authorization code request .
126. Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlowTests.TestFetchTokenAsync_RefreshTokenRequest
Code with line numbers
public TestFetchTokenAsync_RefreshTokenRequest(){(line 320)
var handler = new FetchTokenMessageHandler();(line 323)
handler.RefreshTokenRequest = new RefreshTokenRequest();(line 324)
MockHttpClientFactory mockFactory = new MockHttpClientFactory(handler);(line 330)
var flow = CreateFlow(httpClientFactory : mockFactory);(line 332)
var response = flow.FetchTokenAsync("user",handler.RefreshTokenRequest,CancellationToken.None).Result;(line 333)
SubtestTokenResponse(response);(line 334)
}
This unit test case method tests fetch token async refresh token request .
127. Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlowTests.TestFetchTokenAsync_AuthorizationCodeRequest_Error
Code with line numbers
public TestFetchTokenAsync_AuthorizationCodeRequest_Error(){(line 337)
var handler = new FetchTokenMessageHandler();(line 340)
handler.AuthorizationCodeTokenRequest = new AuthorizationCodeTokenRequest();(line 341)
handler.Error = true;(line 347)
SubtestFetchTokenAsync_Error(handler);(line 348)
}
This unit test case method tests fetch token async authorization code request error .
128. Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlowTests.TestFetchTokenAsync_RefreshTokenRequest_Error
Code with line numbers
public TestFetchTokenAsync_RefreshTokenRequest_Error(){(line 351)
var handler = new FetchTokenMessageHandler();(line 354)
handler.RefreshTokenRequest = new RefreshTokenRequest();(line 355)
handler.Error = true;(line 360)
SubtestFetchTokenAsync_Error(handler);(line 361)
}
This unit test case method tests fetch token async refresh token request error .
129. Google.Apis.Auth.OAuth2.Requests.AuthorizationCodeRequestUrlTests.TestConstructor
Code with line numbers
public TestConstructor(){(line 32)
var request = new AuthorizationCodeRequestUrl(AuthorizationCodeUrl);(line 35)
Assert.That(request.AuthorizationServerUrl,Is.EqualTo(AuthorizationCodeUrl));(line 36)
Assert.Null(request.ClientId);(line 37)
Assert.Null(request.RedirectUri);(line 38)
Assert.That(request.ResponseType,Is.EqualTo("code"));(line 39)
Assert.Null(request.Scope);(line 40)
Assert.Null(request.State);(line 41)
}
This unit test case method tests constructor .
This unit test case validates that:
(1) request.AuthorizationServerUrl is equal to AuthorizationCodeUrl
(2) request.ClientId is null.
(3) request.RedirectUri is null.
(4) request.ResponseType is equal to "code"
(5) request.Scope is null.
(6) request.State is null.
130. Google.Apis.Auth.OAuth2.Requests.AuthorizationCodeRequestUrlTests.TestBuild_DefaultValues
Code with line numbers
public TestBuild_DefaultValues(){(line 44)
var request = new AuthorizationCodeRequestUrl(AuthorizationCodeUrl);(line 47)
var uri = request.Build();(line 48)
Assert.That(uri,Is.EqualTo(new Uri(AuthorizationCodeUrl.ToString() + "?response_type=code")));(line 49)
}
This unit test case method tests build default values .
This unit test case includes following focal methods:
(1) var uri = request.Build();(@line 48)
This focal method is related to assertions at line 49
This unit test case validates that:
(1) uri is equal to new Uri(AuthorizationCodeUrl.ToString() + "?response_type=code")
131. Google.Apis.Auth.OAuth2.Requests.AuthorizationCodeRequestUrlTests.TestBuild
Code with line numbers
public TestBuild(){(line 52)
var request = new AuthorizationCodeRequestUrl(AuthorizationCodeUrl);(line 55)
var uri = request.Build();(line 62)
Assert.That(uri,Is.EqualTo(new Uri(AuthorizationCodeUrl.ToString() + "?response_type=code&client_id=100&redirect_uri=200&scope=SCOPE&state=state")));(line 63)
}
This unit test case method tests build .
This unit test case includes following focal methods:
(1) var uri = request.Build();(@line 62)
This focal method is related to assertions at line 63
This unit test case validates that:
(1) uri is equal to new Uri(AuthorizationCodeUrl.ToString() + "?response_type=code&client_id=100&redirect_uri=200&scope=SCOPE&state=state")
132. Google.Apis.Auth.OAuth2.Requests.AuthorizationCodeRequestUrlTests.TestBuild_EscapeValues
Code with line numbers
public TestBuild_EscapeValues(){(line 67)
var request = new AuthorizationCodeRequestUrl(AuthorizationCodeUrl);(line 70)
var uri = request.Build();(line 77)
Assert.That(uri,Is.EqualTo(new Uri(AuthorizationCodeUrl.ToString() + "?response_type=code&client_id=pa%24%24word&redirect_uri=%3F%3F%3F&scope=SC%40PE&state=%21")));(line 78)
}
This unit test case method tests build escape values .
This unit test case includes following focal methods:
(1) var uri = request.Build();(@line 77)
This focal method is related to assertions at line 78
This unit test case validates that:
(1) uri is equal to new Uri(AuthorizationCodeUrl.ToString() + "?response_type=code&client_id=pa%24%24word&redirect_uri=%3F%3F%3F&scope=SC%40PE&state=%21")
133. Google.Apis.Auth.OAuth2.Requests.AuthorizationCodeTokenRequestTests.TestConstructor
Code with line numbers
public TestConstructor(){(line 32)
var request = new AuthorizationCodeTokenRequest();(line 35)
Assert.Null(request.Code);(line 36)
Assert.Null(request.ClientId);(line 37)
Assert.Null(request.ClientSecret);(line 38)
Assert.Null(request.RedirectUri);(line 39)
Assert.That(request.GrantType,Is.EqualTo("authorization_code"));(line 40)
Assert.Null(request.Scope);(line 41)
}
This unit test case method tests constructor .
This unit test case validates that:
(1) request.Code is null.
(2) request.ClientId is null.
(3) request.ClientSecret is null.
(4) request.RedirectUri is null.
(5) request.GrantType is equal to "authorization_code"
(6) request.Scope is null.
134. Google.Apis.Auth.OAuth2.Requests.GoogleAuthorizationCodeRequestUrlTest.TestConstructor
Code with line numbers
public TestConstructor(){(line 34)
var request = new GoogleAuthorizationCodeRequestUrl(AuthorizationCodeUrl);(line 37)
Assert.That(request.AuthorizationServerUrl,Is.EqualTo(AuthorizationCodeUrl));(line 38)
Assert.Null(request.ClientId);(line 39)
Assert.Null(request.RedirectUri);(line 40)
Assert.That(request.ResponseType,Is.EqualTo("code"));(line 41)
Assert.Null(request.Scope);(line 42)
Assert.Null(request.State);(line 43)
Assert.That(request.AccessType,Is.EqualTo("offline"));(line 44)
Assert.Null(request.ApprovalPrompt);(line 45)
Assert.Null(request.LoginHint);(line 46)
}
This unit test case method tests constructor .
This unit test case validates that:
(1) request.AuthorizationServerUrl is equal to AuthorizationCodeUrl
(2) request.ClientId is null.
(3) request.RedirectUri is null.
(4) request.ResponseType is equal to "code"
(5) request.Scope is null.
(6) request.State is null.
(7) request.AccessType is equal to "offline"
(8) request.ApprovalPrompt is null.
(9) request.LoginHint is null.
135. Google.Apis.Auth.OAuth2.Requests.RefreshTokenRequestTests.TestConstructor
Code with line numbers
public TestConstructor(){(line 32)
var request = new RefreshTokenRequest();(line 35)
Assert.Null(request.Scope);(line 36)
Assert.Null(request.ClientId);(line 37)
Assert.Null(request.ClientSecret);(line 38)
Assert.Null(request.RefreshToken);(line 40)
Assert.That(request.GrantType,Is.EqualTo("refresh_token"));(line 41)
}
This unit test case method tests constructor .
This unit test case validates that:
(1) request.Scope is null.
(2) request.ClientId is null.
(3) request.ClientSecret is null.
(4) request.RefreshToken is null.
(5) request.GrantType is equal to "refresh_token"
136. Google.Apis.Auth.OAuth2.Responses.AuthorizationCodeResponseUrlTests.TestConstructor_Default
Code with line numbers
public TestConstructor_Default(){(line 32)
var response = new AuthorizationCodeResponseUrl();(line 35)
Assert.Null(response.Code);(line 36)
Assert.Null(response.Error);(line 37)
Assert.Null(response.ErrorUri);(line 38)
Assert.Null(response.ErrorDescription);(line 39)
Assert.Null(response.State);(line 40)
}
This unit test case method tests constructor default .
This unit test case validates that:
(1) response.Code is null.
(2) response.Error is null.
(3) response.ErrorUri is null.
(4) response.ErrorDescription is null.
(5) response.State is null.
137. Google.Apis.Auth.OAuth2.Responses.AuthorizationCodeResponseUrlTests.TestConstructor_Dictionary
Code with line numbers
public TestConstructor_Dictionary(){(line 43)
var dic = new Dictionary();(line 46)
dic["code"] = "123";(line 47)
dic["error"] = "ERR";(line 48)
dic["error_uri"] = "URI";(line 49)
dic["error_description"] = "DESC";(line 50)
dic["state"] = "STATE";(line 51)
dic["another_one"] = "BLAH BLAH BLAH";(line 54)
var response = new AuthorizationCodeResponseUrl(dic);(line 56)
SubtestConstructor(response);(line 57)
}
This unit test case method tests constructor dictionary .
138. Google.Apis.Auth.OAuth2.Responses.AuthorizationCodeResponseUrlTests.TestConstructor_Query
Code with line numbers
public TestConstructor_Query(){(line 60)
string query = "code=123&error=ERR&error_uri=URI&error_description=DESC&state=STATE&other_ine=2222222222";(line 63)
var response = new AuthorizationCodeResponseUrl(query);(line 64)
SubtestConstructor(response);(line 65)
}
This unit test case method tests constructor query .
139. Google.Apis.Auth.OAuth2.Responses.TokenResponseTests.TestConstructor
Code with line numbers
public TestConstructor(){(line 35)
var response = new TokenResponse();(line 38)
Assert.Null(response.AccessToken);(line 39)
Assert.Null(response.ExpiresInSeconds);(line 40)
Assert.Null(response.RefreshToken);(line 41)
Assert.Null(response.Scope);(line 42)
Assert.AreEqual(DateTime.MinValue,response.Issued);(line 43)
}
This unit test case method tests constructor .
This unit test case validates that:
(1) response.AccessToken is null.
(2) response.ExpiresInSeconds is null.
(3) response.RefreshToken is null.
(4) response.Scope is null.
(5) response.Issued is equal to DateTime.MinValue.
140. Google.Apis.Auth.OAuth2.Responses.TokenResponseTests.TestSerializer
Code with line numbers
public TestSerializer(){(line 46)
var tokenResponse = JsonConvert.DeserializeObject<TokenResponse>(@"{
'access_token': '123',
'expires_in': 1000,
'refresh_token': '456',
'scope': '789'
}");(line 49)
Assert.That(tokenResponse.AccessToken,Is.EqualTo("123"));(line 56)
Assert.That(tokenResponse.RefreshToken,Is.EqualTo("456"));(line 57)
Assert.That(tokenResponse.Scope,Is.EqualTo("789"));(line 58)
Assert.That(tokenResponse.ExpiresInSeconds,Is.EqualTo(1000));(line 59)
}
This unit test case method tests serializer .
This unit test case validates that:
(1) tokenResponse.AccessToken is equal to "123"
(2) tokenResponse.RefreshToken is equal to "456"
(3) tokenResponse.Scope is equal to "789"
(4) tokenResponse.ExpiresInSeconds is equal to 1000
141. Google.Apis.Auth.OAuth2.Responses.TokenResponseTests.IsExpired
Code with line numbers
public IsExpired(){(line 62)
var issued = DateTime.Now;(line 65)
var newNow = DateTime.Now.AddSeconds(100);(line 66)
var mockClock = new MockClock;(line 68)
var response = new TokenResponse();(line 74)
Assert.True(response.IsExpired(mockClock));(line 75)
response = new TokenResponse();(line 78)
Assert.True(response.IsExpired(mockClock));(line 79)
response = new TokenResponse();(line 81)
Assert.True(response.IsExpired(mockClock));(line 82)
response = new TokenResponse();(line 84)
Assert.True(response.IsExpired(mockClock));(line 85)
response = new TokenResponse();(line 87)
Assert.True(response.IsExpired(mockClock));(line 88)
response = new TokenResponse();(line 90)
Assert.True(response.IsExpired(mockClock));(line 91)
response = new TokenResponse();(line 93)
Assert.True(response.IsExpired(mockClock));(line 94)
response = new TokenResponse();(line 96)
Assert.False(response.IsExpired(mockClock));(line 97)
response = new TokenResponse();(line 99)
Assert.False(response.IsExpired(mockClock));(line 100)
}
This unit test case method tests check if tokenresponsetests is expired .
This unit test case includes following focal methods:
(1) An assertion in line 75 validating that response.IsExpired(mockClock) is true.
(2) An assertion in line 79 validating that response.IsExpired(mockClock) is true.
(3) An assertion in line 82 validating that response.IsExpired(mockClock) is true.
(4) An assertion in line 85 validating that response.IsExpired(mockClock) is true.
(5) An assertion in line 88 validating that response.IsExpired(mockClock) is true.
(6) An assertion in line 91 validating that response.IsExpired(mockClock) is true.
(7) An assertion in line 94 validating that response.IsExpired(mockClock) is true.
(8) An assertion in line 97 validating that response.IsExpired(mockClock) is false.
(9) An assertion in line 100 validating that response.IsExpired(mockClock) is false.
142. Google.Apis.Auth.OAuth2.BearerTokenTests.AuthorizationHeaderAccessMethod_Intercept
Code with line numbers
public AuthorizationHeaderAccessMethod_Intercept(){(line 32)
var request = new HttpRequestMessage();(line 35)
new BearerToken.AuthorizationHeaderAccessMethod().Intercept(request,"abc");(line 36)
Assert.That(request.Headers.Authorization.ToString(),Is.EqualTo("Bearer abc"));(line 37)
}
This unit test case method tests handle authorization header access method intercept .
This unit test case validates that:
(1) request.Headers.Authorization.ToString() is equal to "Bearer abc"
143. Google.Apis.Auth.OAuth2.BearerTokenTests.AuthorizationHeaderAccessMethod_InterceptOverride
Code with line numbers
public AuthorizationHeaderAccessMethod_InterceptOverride(){(line 40)
var request = new HttpRequestMessage();(line 43)
request.Headers.Authorization = new AuthenticationHeaderValue("a","1");(line 44)
new BearerToken.AuthorizationHeaderAccessMethod().Intercept(request,"abc");(line 45)
Assert.That(request.Headers.Authorization.ToString(),Is.EqualTo("Bearer abc"));(line 46)
}
This unit test case method tests handle authorization header access method intercept override .
This unit test case validates that:
(1) request.Headers.Authorization.ToString() is equal to "Bearer abc"
144. Google.Apis.Auth.OAuth2.BearerTokenTests.AuthorizationHeaderAccessMethod_GetAccessToken
Code with line numbers
public AuthorizationHeaderAccessMethod_GetAccessToken(){(line 49)
var request = new HttpRequestMessage();(line 52)
request.Headers.Authorization = new AuthenticationHeaderValue("a","1");(line 53)
var accessToken = new BearerToken.AuthorizationHeaderAccessMethod().GetAccessToken(request);(line 54)
Assert.IsNullOrEmpty(accessToken);(line 55)
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer","abc");(line 57)
accessToken = new BearerToken.AuthorizationHeaderAccessMethod().GetAccessToken(request);(line 58)
Assert.That(accessToken,Is.EqualTo("abc"));(line 59)
}
This unit test case method tests handle authorization header access method get access token .
This unit test case validates that:
(1) accessToken is null or empty.
   accessToken is obtained from
   1) variable request through slicing path.
(2) accessToken is equal to "abc"
   accessToken is obtained from
   1) variable request through slicing path.
145. Google.Apis.Auth.OAuth2.BearerTokenTests.QueryParameterAccessMethod_Intercept
Code with line numbers
public QueryParameterAccessMethod_Intercept(){(line 62)
var request = new HttpRequestMessage(HttpMethod.Get,new Uri("https://sample.com/path"));(line 65)
new BearerToken.QueryParameterAccessMethod().Intercept(request,"abc");(line 66)
Assert.That(request.RequestUri,Is.EqualTo(new Uri("https://sample.com/path?access_token=abc")));(line 67)
}
This unit test case method tests query parameter access method intercept .
This unit test case validates that:
(1) request.RequestUri is equal to new Uri("https://sample.com/path?access_token=abc")
146. Google.Apis.Auth.OAuth2.BearerTokenTests.QueryParameterAccessMethod_Intercept_WithQueryParameters
Code with line numbers
public QueryParameterAccessMethod_Intercept_WithQueryParameters(){(line 70)
var request = new HttpRequestMessage(HttpMethod.Get,new Uri("https://sample.com/path?a=1"));(line 73)
new BearerToken.QueryParameterAccessMethod().Intercept(request,"abc");(line 74)
Assert.That(request.RequestUri,Is.EqualTo(new Uri("https://sample.com/path?a=1&access_token=abc")));(line 75)
}
This unit test case method tests query parameter access method intercept with query parameters.
This unit test case validates that:
(1) request.RequestUri is equal to new Uri("https://sample.com/path?a=1&access_token=abc")
147. Google.Apis.Auth.OAuth2.BearerTokenTests.QueryParameterAccessMethod_GetAccessToken
Code with line numbers
public QueryParameterAccessMethod_GetAccessToken(){(line 78)
var request = new HttpRequestMessage(HttpMethod.Get,new Uri("https://sample.com"));(line 82)
var accessToken = new BearerToken.QueryParameterAccessMethod().GetAccessToken(request);(line 83)
Assert.IsNullOrEmpty(accessToken);(line 84)
request = new HttpRequestMessage(HttpMethod.Get,new Uri("https://sample.com?a=1"));(line 87)
accessToken = new BearerToken.QueryParameterAccessMethod().GetAccessToken(request);(line 88)
Assert.IsNullOrEmpty(accessToken);(line 89)
request = new HttpRequestMessage(HttpMethod.Get,new Uri("https://sample.com?a=1&access_token=abc"));(line 92)
accessToken = new BearerToken.QueryParameterAccessMethod().GetAccessToken(request);(line 93)
Assert.That(accessToken,Is.EqualTo("abc"));(line 94)
request = new HttpRequestMessage(HttpMethod.Get,new Uri("https://sample.com?access_token=abc"));(line 97)
accessToken = new BearerToken.QueryParameterAccessMethod().GetAccessToken(request);(line 98)
Assert.That(accessToken,Is.EqualTo("abc"));(line 99)
}
This unit test case method tests query parameter access method get access token .
This unit test case validates that:
(1) accessToken is null or empty.
   accessToken is obtained from
   1) variable request through slicing path.
(2) accessToken is null or empty.
   accessToken is obtained from
   1) variable request through slicing path.
(3) accessToken is equal to "abc"
   accessToken is obtained from
   1) variable request through slicing path.
(4) accessToken is equal to "abc"
   accessToken is obtained from
   1) variable request through slicing path.
148. Google.Apis.Auth.OAuth2.ComputeCredentialTests.IsRunningOnComputeEngine
Code with line numbers
public IsRunningOnComputeEngine(){(line 25)
Assert.IsFalse(ComputeCredential.IsRunningOnComputeEngine().Result);(line 29)
}
This unit test case method tests check if computecredentialtests is running on compute engine.
This unit test case validates that:
(1) ComputeCredential.IsRunningOnComputeEngine().Result is false.
149. Google.Apis.Auth.OAuth2.ComputeCredentialTests.IsRunningOnComputeEngine_ResultIsCached
Code with line numbers
public IsRunningOnComputeEngine_ResultIsCached(){(line 32)
Assert.AreSame(ComputeCredential.IsRunningOnComputeEngine(),ComputeCredential.IsRunningOnComputeEngine());(line 36)
}
This unit test case method tests check if computecredentialtests is running on compute engine result is cached.
This unit test case validates that:
(1) ComputeCredential.IsRunningOnComputeEngine() and ComputeCredential.IsRunningOnComputeEngine() are same.
150. Google.Apis.Auth.OAuth2.DefaultCredentialProviderTests.GetDefaultCredential_UserCredential_FromEnvironmentVariable
Code with line numbers
public Task GetDefaultCredential_UserCredential_FromEnvironmentVariable(){(line 129)
var credentialFilepath = "TempFilePath.json";(line 133)
credentialProvider.SetEnvironmentVariable(CredentialEnvironmentVariable,credentialFilepath);(line 134)
credentialProvider.SetFileContents(credentialFilepath,DummyUserCredentialFileContents);(line 135)
var credential = await credentialProvider.GetDefaultCredentialAsync();(line 137)
Assert.IsInstanceOf(typeof(UserCredential),credential.UnderlyingCredential);(line 139)
Assert.IsFalse(credential.IsCreateScopedRequired);(line 140)
Assert.AreSame(credential,credential.CreateScoped(new));(line 141)
}
This unit test case method tests get default credential user credential from environment variable.
This unit test case validates that:
(1) credential.UnderlyingCredential is a instance of typeof(UserCredential).
(2) credential.IsCreateScopedRequired is false.
(3) credential.CreateScoped(new) and credential are same.
151. Google.Apis.Auth.OAuth2.DefaultCredentialProviderTests.GetDefaultCredential_UserCredential_FromWellKnownFileLocation
Code with line numbers
public Task GetDefaultCredential_UserCredential_FromWellKnownFileLocation(){(line 144)
credentialProvider.SetEnvironmentVariable("APPDATA",AppDataValue);(line 148)
credentialProvider.SetFileContents(WellKnownCredentialFilePath,DummyUserCredentialFileContents);(line 149)
var credential = await credentialProvider.GetDefaultCredentialAsync();(line 151)
Assert.IsInstanceOf(typeof(UserCredential),credential.UnderlyingCredential);(line 153)
Assert.IsFalse(credential.IsCreateScopedRequired);(line 154)
Assert.AreSame(credential,credential.CreateScoped(new));(line 155)
}
This unit test case method tests get default credential user credential from well known file location.
This unit test case validates that:
(1) credential.UnderlyingCredential is a instance of typeof(UserCredential).
(2) credential.IsCreateScopedRequired is false.
(3) credential.CreateScoped(new) and credential are same.
152. Google.Apis.Auth.OAuth2.DefaultCredentialProviderTests.GetDefaultCredential_UserCredential_FromWellKnownFileLocationUnix
Code with line numbers
public Task GetDefaultCredential_UserCredential_FromWellKnownFileLocationUnix(){(line 158)
credentialProvider.SetEnvironmentVariable("HOME",HomeValue);(line 162)
credentialProvider.SetFileContents(WellKnownCredentialFilePathUnix,DummyUserCredentialFileContents);(line 163)
var credential = await credentialProvider.GetDefaultCredentialAsync();(line 165)
Assert.IsInstanceOf(typeof(UserCredential),credential.UnderlyingCredential);(line 167)
Assert.IsFalse(credential.IsCreateScopedRequired);(line 168)
}
This unit test case method tests get default credential user credential from well known file location unix.
This unit test case validates that:
(1) credential.UnderlyingCredential is a instance of typeof(UserCredential).
(2) credential.IsCreateScopedRequired is false.
153. Google.Apis.Auth.OAuth2.DefaultCredentialProviderTests.GetDefaultCredential_ServiceAccountCredential_FromEnvironmentVariable
Code with line numbers
public Task GetDefaultCredential_ServiceAccountCredential_FromEnvironmentVariable(){(line 175)
var credentialFilepath = "TempFilePath.json";(line 179)
credentialProvider.SetEnvironmentVariable(CredentialEnvironmentVariable,credentialFilepath);(line 180)
credentialProvider.SetFileContents(credentialFilepath,DummyServiceAccountCredentialFileContents);(line 181)
var credential = await credentialProvider.GetDefaultCredentialAsync();(line 183)
Assert.IsInstanceOf(typeof(ServiceAccountCredential),credential.UnderlyingCredential);(line 185)
Assert.IsTrue(credential.IsCreateScopedRequired);(line 186)
var scopes = new;(line 188)
var scopedCredential = credential.CreateScoped(scopes);(line 189)
Assert.AreNotSame(credential,scopedCredential);(line 190)
Assert.IsInstanceOf(typeof(ServiceAccountCredential),scopedCredential.UnderlyingCredential);(line 192)
Assert.IsFalse(scopedCredential.IsCreateScopedRequired);(line 193)
CollectionAssert.AreEqual(scopes,ServiceAccountCredential scopedCredential.UnderlyingCredential.Scopes);(line 194)
}
This unit test case method tests get default credential service account credential from environment variable.
This unit test case validates that:
(1) credential.UnderlyingCredential is a instance of typeof(ServiceAccountCredential).
(2) credential.IsCreateScopedRequired is true.
(3) scopedCredential and credential are not same.
   scopedCredential is obtained from
   1) variable scopes through slicing path.
(4) scopedCredential.UnderlyingCredential is a instance of typeof(ServiceAccountCredential).
   scopedCredential is obtained from
   1) variable scopes through slicing path.
(5) scopedCredential.IsCreateScopedRequired is false.
   scopedCredential is obtained from
   1) variable scopes through slicing path.
154. Google.Apis.Auth.OAuth2.DefaultCredentialProviderTests.GetDefaultCredential_NoCredentialFiles
Code with line numbers
public Task GetDefaultCredential_NoCredentialFiles(){(line 202)
try(line 205)
var credential = await credentialProvider.GetDefaultCredentialAsync();(line 207)
Assert.Fail();(line 208)
catch(InvalidOperationException e)(line 210)
Assert.IsTrue(e.Message.Contains("The Application Default Credentials are not available"));(line 212)
}
This unit test case method tests get default credential no credential files .
This unit test case validates that:
(1) Fail at line 208.
(2) e.Message.Contains("The Application Default Credentials are not available") is true.
155. Google.Apis.Auth.OAuth2.DefaultCredentialProviderTests.GetDefaultCredential_MissingCredentialFile
Code with line numbers
public Task GetDefaultCredential_MissingCredentialFile(){(line 217)
credentialProvider.SetEnvironmentVariable(CredentialEnvironmentVariable,WellKnownCredentialFilePath);(line 221)
try(line 223)
var credential = await credentialProvider.GetDefaultCredentialAsync();(line 225)
Assert.Fail();(line 226)
catch(InvalidOperationException e)(line 228)
Assert.IsTrue(e.Message.Contains("Please check the value of the Environment Variable GOOGLE_APPLICATION_CREDENTIALS"));(line 230)
}
This unit test case method tests get default credential missing credential file .
This unit test case validates that:
(1) Fail at line 226.
(2) e.Message.Contains("Please check the value of the Environment Variable GOOGLE_APPLICATION_CREDENTIALS") is true.
156. Google.Apis.Auth.OAuth2.DefaultCredentialProviderTests.GetDefaultCredential_InvalidCredentialFile
Code with line numbers
public Task GetDefaultCredential_InvalidCredentialFile(){(line 235)
var credentialFilepath = "TempFilePath.json";(line 239)
credentialProvider.SetEnvironmentVariable(CredentialEnvironmentVariable,credentialFilepath);(line 240)
credentialProvider.SetFileContents(credentialFilepath,"Invalid Credentials File Contents");(line 241)
try(line 243)
var credential = await credentialProvider.GetDefaultCredentialAsync();(line 245)
Assert.Fail();(line 246)
catch(InvalidOperationException e)(line 248)
Assert.IsTrue(e.Message.Contains("Error reading credential file from location"));(line 250)
}
This unit test case method tests get default credential invalid credential file .
This unit test case validates that:
(1) Fail at line 246.
(2) e.Message.Contains("Error reading credential file from location") is true.
157. Google.Apis.Auth.OAuth2.DefaultCredentialProviderTests.GetDefaultCredential_BrokenPkcs8Key
Code with line numbers
public Task GetDefaultCredential_BrokenPkcs8Key(){(line 255)
var credentialFilepath = "TempFilePath.json";(line 259)
credentialProvider.SetEnvironmentVariable(CredentialEnvironmentVariable,credentialFilepath);(line 260)
credentialProvider.SetFileContents(credentialFilepath,BrokenPkcs8KeyServiceAccountCredentialFileContents);(line 261)
try(line 263)
var credential = await credentialProvider.GetDefaultCredentialAsync();(line 265)
Assert.Fail();(line 266)
catch(InvalidOperationException e)(line 268)
Assert.IsTrue(e.Message.Contains("Error reading credential file from location"));(line 270)
}
This unit test case method tests get default credential broken pkcs 8 key .
This unit test case validates that:
(1) Fail at line 266.
(2) e.Message.Contains("Error reading credential file from location") is true.
158. Google.Apis.Auth.OAuth2.GoogleCredentialTests.FromStream_UserCredential
Code with line numbers
public FromStream_UserCredential(){(line 60)
var stream = new MemoryStream(Encoding.UTF8.GetBytes(DummyUserCredentialFileContents));(line 63)
var credential = GoogleCredential.FromStream(stream);(line 64)
Assert.IsFalse(credential.IsCreateScopedRequired);(line 65)
}
This unit test case method tests convert from stream user credential .
This unit test case validates that:
(1) credential.IsCreateScopedRequired is false.
159. Google.Apis.Auth.OAuth2.GoogleCredentialTests.FromStream_ServiceAccountCredential
Code with line numbers
public FromStream_ServiceAccountCredential(){(line 68)
var stream = new MemoryStream(Encoding.UTF8.GetBytes(DummyServiceAccountCredentialFileContents));(line 71)
var credential = GoogleCredential.FromStream(stream);(line 72)
Assert.IsInstanceOf(typeof(ServiceAccountCredential),credential.UnderlyingCredential);(line 73)
Assert.IsTrue(credential.IsCreateScopedRequired);(line 74)
}
This unit test case method tests convert from stream service account credential .
This unit test case validates that:
(1) credential.UnderlyingCredential is a instance of typeof(ServiceAccountCredential).
(2) credential.IsCreateScopedRequired is true.
160. Google.Apis.Auth.OAuth2.GoogleCredentialTests.FromStream_ServiceAccountCredential_GetJwtAccessToken
Code with line numbers
public Task FromStream_ServiceAccountCredential_GetJwtAccessToken(){(line 82)
var stream = new MemoryStream(Encoding.UTF8.GetBytes(DummyServiceAccountCredentialFileContents));(line 85)
var credential = GoogleCredential.FromStream(stream);(line 86)
string accessToken = await credential as ITokenAccess.GetAccessTokenForRequestAsync(DummyAuthUri);(line 89)
var parts = accessToken.Split(new);(line 90)
Assert.AreEqual(3,parts.Length);(line 91)
var header = NewtonsoftJsonSerializer.Instance.Deserialize<JsonWebSignature.Header>(UrlSafeDecode64(parts[0]));(line 93)
Assert.AreEqual("JWT",header.Type);(line 94)
Assert.AreEqual("RS256",header.Algorithm);(line 95)
var payload = NewtonsoftJsonSerializer.Instance.Deserialize<JsonWebSignature.Payload>(UrlSafeDecode64(parts[1]));(line 97)
Assert.AreEqual("CLIENT_EMAIL",payload.Issuer);(line 99)
Assert.AreEqual("CLIENT_EMAIL",payload.Subject);(line 100)
Assert.AreEqual(DummyAuthUri,payload.Audience);(line 101)
Assert.AreEqual(3600,payload.ExpirationTimeSeconds - payload.IssuedAtTimeSeconds);(line 102)
}
This unit test case method tests convert from stream service account credential get jwt access token .
This unit test case validates that:
(1) parts.Length is equal to 3.
(2) header.Type is equal to "JWT".
(3) header.Algorithm is equal to "RS256".
(4) payload.Issuer is equal to "CLIENT_EMAIL".
(5) payload.Subject is equal to "CLIENT_EMAIL".
(6) payload.Audience is equal to DummyAuthUri.
(7) payload.ExpirationTimeSeconds - payload.IssuedAtTimeSeconds is equal to 3600.
161. TestJSonReader.JSONReaderTest.ParseTest
Code with line numbers
public ParseTest(){(line 67)
string jsonAsText = "[ true, \"Value2\", false, null ]";(line 69)
object o = JSONReader.Parse(jsonAsText);(line 70)
Assert.IsTrue(o is ArrayList);(line 71)
ArrayList a = o as ArrayList;(line 72)
Assert.AreEqual(4,a.Count);(line 73)
Assert.AreEqual(false,a[2]);(line 74)
jsonAsText = "{ \"Name\" : true }";(line 76)
o = JSONReader.Parse(jsonAsText);(line 77)
Assert.IsTrue(o is JSONDictionary);(line 78)
jsonAsText = "{ \"name\" : [ true, \"Value2\", false ], \"sub\" : { \"subname\" : 1234 } }";(line 80)
o = JSONReader.Parse(jsonAsText);(line 81)
Assert.IsTrue(o is JSONDictionary);(line 82)
JSONDictionary j = o as JSONDictionary;(line 83)
a = j["name"] as ArrayList;(line 84)
Assert.IsNotNull(a);(line 85)
}
This unit test case method tests parse test .
This unit test case validates that:
(1) o is ArrayList is true.
   o is obtained from
   1) variable jsonAsText through slicing path.
(2) a.Count is equal to 4.
   a is obtained from
   1) variable jsonAsText through slicing path.
(3) a[2] is equal to false.
   a is obtained from
   1) variable jsonAsText through slicing path.
(4) o is JSONDictionary is true.
   o is obtained from
   1) variable jsonAsText through slicing path.
(5) o is JSONDictionary is true.
   o is obtained from
   1) variable jsonAsText through slicing path.
(6) a is not null.
   a is obtained from
   1) variable jsonAsText through slicing path.
162. TestJSonReader.JSONTokenTest.JSONTokenConstructorTest
Code with line numbers
public JSONTokenConstructorTest(){(line 64)
JSONToken target = new JSONToken();(line 66)
Assert.Inconclusive("TODO: Implement code to verify target");(line 67)
}
This unit test case method tests json token constructor test .
This unit test case validates that:
(1) The assertion cannot be verified at line 67.