/// <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 AddMediaAsync(AddMediaQuery query)
 {
     await _requestSender.SendRequestAsync(new ApiRequest
     {
         Path       = $"/api/v4/collections/{query.CollectionId}/media/",
         HTTPMethod = HttpMethod.Post,
         Query      = query,
     }).ConfigureAwait(false);
 }
Example #2
0
        /// <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 AddMediaAsync(AddMediaQuery query)
        {
            var request = new Request <string>
            {
                Uri                 = $"/api/v4/collections/{query.CollectionId}/media/",
                HTTPMethod          = HttpMethod.Post,
                Query               = query,
                DeserializeResponse = false
            };

            return(_requestSender.SendRequestAsync(request));
        }
Example #3
0
        public async Task AddMediaAsyncCallsRequestSenderWithValidRequest()
        {
            var result = new { message = "Accepted", statuscode = 202 };

            _apiRequestSenderMock.Setup(sender => sender.SendRequestAsync(It.IsAny <ApiRequest>()))
            .ReturnsAsync(result);
            var addMediaQuery = new AddMediaQuery("collectionId", new List <string>());
            await _collectionService.AddMediaAsync(addMediaQuery);

            _apiRequestSenderMock.Verify(sender => sender.SendRequestAsync(
                                             It.Is <ApiRequest>(
                                                 req => req.Path == $"/api/v4/collections/{addMediaQuery.CollectionId}/media/" &&
                                                 req.Query == addMediaQuery &&
                                                 req.HTTPMethod == HttpMethod.Post
                                                 )
                                             ));
        }
Example #4
0
        public async Task WhenAddMediaAsyncCalledContainsExpectedResult(string id, string mediaId)
        {
            var query = new AddMediaQuery(id, new[] { mediaId });

            IList <string> mediaList = new List <string>();
            var            mock      = new Mock <IOauthRequestSender>();

            mock.Setup(reqSenderMock => reqSenderMock.SendRequestAsync(It.IsAny <Request <string> >())).Returns(Task.FromResult(string.Empty));

            var manager = new CollectionsManager(mock.Object);
            await manager.AddMediaAsync(query);

            mock.Verify(reqSenderMock
                        => reqSenderMock.SendRequestAsync(It.Is <Request <string> >(req => req.Uri == $"/api/v4/collections/{id}/media/" &&
                                                                                    req.HTTPMethod == HttpMethod.Post &&
                                                                                    ((AddMediaQuery)req.Query).MediaIds.Contains(mediaId))));
        }
Example #5
0
        public async Task AddMediaAsyncCallsRequestSenderWithValidRequest()
        {
            var apiRequestSender = new Mock <IApiRequestSender>();
            var result           = "";

            apiRequestSender.Setup(sender => sender.SendRequestAsync(It.IsAny <Request <string> >()))
            .Returns(Task.FromResult(result));
            var collectionService = new CollectionService(apiRequestSender.Object);
            var addMediaQuery     = new AddMediaQuery("collectionId", new List <string>());
            await collectionService.AddMediaAsync(addMediaQuery);

            apiRequestSender.Verify(sender => sender.SendRequestAsync(
                                        It.Is <Request <string> >(
                                            req => req.Path == $"/api/v4/collections/{addMediaQuery.CollectionId}/media/" &&
                                            req.Query == addMediaQuery &&
                                            req.HTTPMethod == HttpMethod.Post &&
                                            req.DeserializeResponse == false)));
        }