コード例 #1
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
                                                 )
                                             ));
        }
コード例 #2
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)));
        }