public async Task IfListApplicationSummariesReturnsNoSkipToken_ThenNoFurtherCallsAreMade() { var fakeResponse = @"{ ""value"" : [ { ""id"" : ""app1"", ""versions"" : [ ""1"", ""2"" ] }, { ""id"" : ""app2"", ""versions"" : [ ""beta"" ] }, { ""id"" : ""app3"", ""versions"" : [ ""1"", ""2"" ] } ] }"; var requests = new List <Uri>(); var results = new List <Microsoft.Azure.Batch.ApplicationSummary>(); Func <Uri, string> responseBody = uri => { requests.Add(uri); return(fakeResponse); }; using (BatchClient client = BatchClient.Open(FakeClient.Create(HttpStatusCode.OK, responseBody))) { results = await client.ApplicationOperations.ListApplicationSummaries().ToListAsync(); } Assert.Single(requests); Assert.Equal(3, results.Count); Assert.Equal("app1", results[0].Id); Assert.Equal("app3", results[2].Id); }
public async Task IfListApplicationSummariesReturnsASkipToken_ThenFurtherCallsAreMadeUntilItDoesnt() { var fakeResponse1 = @"{ ""value"" : [ { ""id"" : ""app1"", ""versions"" : [ ""1"", ""2"" ] }, { ""id"" : ""app2"", ""versions"" : [ ""beta"" ] } ], ""odata.nextLink"" : ""http://skip1/"", }"; var fakeResponse2 = @"{ ""value"" : [ { ""id"" : ""app3"", ""versions"" : [ ""1"", ""2"" ] }, { ""id"" : ""app4"", ""versions"" : [ ""beta"" ] } ], ""odata.nextLink"" : ""http://skip2/"", }"; var fakeResponse3 = @"{ ""value"" : [ { ""id"" : ""app5"", ""versions"" : [ ""1"", ""2"" ] } ] }"; var requests = new List <Uri>(); var results = new List <Microsoft.Azure.Batch.ApplicationSummary>(); Func <Uri, string> responseBody = uri => { requests.Add(uri); switch (uri.AbsoluteUri) { case "http://skip1/": return(fakeResponse2); case "http://skip2/": return(fakeResponse3); default: return(fakeResponse1); } }; using (BatchClient client = BatchClient.Open(FakeClient.Create(HttpStatusCode.OK, responseBody))) { results = await client.ApplicationOperations.ListApplicationSummaries().ToListAsync(); } Assert.Equal(3, requests.Count); Assert.Equal(5, results.Count); Assert.Equal("app1", results[0].Id); Assert.Equal("app5", results[4].Id); }