public async Task GetBlobMetadata() { SetUpMockAuth(); string response = "{'blobs':[" + "{'fileName':'test1.txt,config','etag':'','size':2}," + "{'fileName':'test11.txt,binary','etag':'','size':2}," + "{'fileName':'test2.txt,config','etag':'','size':2}," + "{'fileName':'test3.txt,config','etag':'','size':2}," + "{'fileName':'test4.txt,config','etag':'','size':2}," + "{'fileName':'test5.txt,config','etag':'','size':2}" + "]," + "'pagingInfo':{'totalItems':8,'continuationToken':'123456'}}"; var uri = new Uri(new Uri(ClientSettings.Singleton.TitleStorageEndpoint), $"global/scids/{DefaultScid}/data/{DefaultGlobalStoragePath}?maxItems={DefaultMaxItems}&skipItems={DefaultSkipItems}"); var mockHttp = new MockHttpMessageHandler(); mockHttp.Expect(uri.ToString()) .Respond("application/json", response); TestHook.MockHttpHandler = mockHttp; var metadataResult = await TitleStorage.GetGlobalStorageBlobMetaData(DefaultScid, DefaultSandbox, DefaultGlobalStoragePath, DefaultMaxItems, DefaultSkipItems); Assert.AreEqual((uint)8, metadataResult.TotalItems); Assert.AreEqual(6, metadataResult.Items.Count()); Assert.IsTrue(metadataResult.HasNext); // GetNextAsync var nextPageUri = new Uri(new Uri(ClientSettings.Singleton.TitleStorageEndpoint), $"global/scids/{DefaultScid}/data/{DefaultGlobalStoragePath}?maxItems={DefaultMaxItems}&continuationToken=123456"); mockHttp.Expect(nextPageUri.ToString()) .Respond("application/json", response); var metaResult1 = await metadataResult.GetNextAsync(DefaultMaxItems); Assert.AreEqual((uint)8, metadataResult.TotalItems); Assert.AreEqual(6, metadataResult.Items.Count()); Assert.IsTrue(metadataResult.HasNext); }
public async Task GetBlobMetadataNotFound() { SetUpMockAuth(); var uri = new Uri(new Uri(ClientSettings.Singleton.TitleStorageEndpoint), $"global/scids/{DefaultScid}/data/{DefaultGlobalStoragePath}"); var mockHttp = new MockHttpMessageHandler(); mockHttp.Expect(uri.ToString()) .Respond(HttpStatusCode.NotFound); TestHook.MockHttpHandler = mockHttp; var metadataResult = await TitleStorage.GetGlobalStorageBlobMetaData(DefaultScid, DefaultSandbox, DefaultGlobalStoragePath, DefaultMaxItems, DefaultSkipItems); Assert.AreEqual((uint)0, metadataResult.TotalItems); Assert.AreEqual(0, metadataResult.Items.Count()); Assert.IsFalse(metadataResult.HasNext); }