/// <summary> /// Check <see cref="ICollectionService"/> for more information /// </summary> /// <param name="query">Check <see cref="ICollectionService"/> for more information</param> /// <returns>Check <see cref="ICollectionService"/> for more information</returns> public async Task <IList <Model.Collection> > GetCollectionsAsync(GetCollectionsQuery query) { return(await _requestSender.SendRequestAsync(new ApiRequest <IList <Model.Collection> > { Path = "/api/v4/collections/", HTTPMethod = HttpMethod.Get, Query = query, }).ConfigureAwait(false)); }
/// <summary> /// Check <see cref="ICollectionsManager"/> for more information /// </summary> /// <param name="query">Check <see cref="ICollectionsManager"/> for more information</param> /// <returns>Check <see cref="ICollectionsManager"/> for more information</returns> public Task <IList <Collection> > GetCollectionsAsync(GetCollectionsQuery query) { var request = new Request <IList <Collection> > { Uri = "/api/v4/collections/", HTTPMethod = HttpMethod.Get, Query = query }; return(_requestSender.SendRequestAsync(request)); }
public async Task GetCollectionsCallsRequestSenderWithValidRequest() { var result = new List <Sdk.Model.Collection>(); _apiRequestSenderMock.Setup(sender => sender.SendRequestAsync(It.IsAny <ApiRequest <IList <Sdk.Model.Collection> > >())) .ReturnsAsync(result); var getCollectionsQuery = new GetCollectionsQuery(); var collectionList = await _collectionService.GetCollectionsAsync(getCollectionsQuery); _apiRequestSenderMock.Verify(sender => sender.SendRequestAsync( It.Is <ApiRequest <IList <Sdk.Model.Collection> > >( req => req.Path == "/api/v4/collections/" && req.Query == getCollectionsQuery && req.HTTPMethod == HttpMethod.Get ) )); Assert.Equal(result, collectionList); }
public async Task GetCollectionsCallsRequestSenderWithValidRequest() { var apiRequestSender = new Mock <IApiRequestSender>(); var result = (IList <Bynder.Sdk.Model.Collection>) new List <Bynder.Sdk.Model.Collection>(); apiRequestSender.Setup(sender => sender.SendRequestAsync(It.IsAny <Request <IList <Bynder.Sdk.Model.Collection> > >())) .Returns(Task.FromResult(result)); var collectionService = new CollectionService(apiRequestSender.Object); var getCollectionsQuery = new GetCollectionsQuery(); var collectionList = await collectionService.GetCollectionsAsync(getCollectionsQuery); apiRequestSender.Verify(sender => sender.SendRequestAsync( It.Is <Request <IList <Bynder.Sdk.Model.Collection> > >( req => req.Path == "/api/v4/collections/" && req.Query == getCollectionsQuery && req.HTTPMethod == HttpMethod.Get))); Assert.Equal(result, collectionList); }
public async Task WhenGetCollectionsAsyncCalledContainsExpectedResult() { var query = new GetCollectionsQuery() { Limit = 50, Page = 1 }; IList <Collection> mediaCollections = new List <Collection>(); var mock = new Mock <IOauthRequestSender>(); mock.Setup(reqSenderMock => reqSenderMock.SendRequestAsync(It.IsAny <Request <IList <Collection> > >())).Returns(Task.FromResult(mediaCollections)); var manager = new CollectionsManager(mock.Object); var collectionList = await manager.GetCollectionsAsync(query); mock.Verify(reqSenderMock => reqSenderMock.SendRequestAsync(It.Is <Request <IList <Collection> > >(req => req.Uri == $"/api/v4/collections/" && req.HTTPMethod == HttpMethod.Get && req.Query == query))); Assert.AreEqual(mediaCollections, collectionList); }