public void WhenRouteToBookServicePost_DispatchReturnsSuccess()
        {
            var request = new PostBookDispatcherRequest
            {
                UserId      = 1, No = 5, Name = "aaa", Tag = "tag", ShelfId = 1, AuthorId = "id", SkinType = 1
                , LibraryId = "id", PublisherId = 1, PublisherDate = Convert.ToDateTime("01.01.2019")
            };

            _bookServiceEndPointsMock.Setup(t => t.Value)
            .Returns(() => new BookServiceEndPointConstants {
                Post = "https://{userid}"
            });

            _dispatcherMock.Setup(t =>
                                  t.Dispatch <object, object>(It.IsAny <object>(), "https://1", null
                                                              , HttpRequestCode.POST, null, null))
            .Verifiable();

            _bookDispatchService = new BookServiceDispatcher(_bookServiceEndPointsMock.Object, _dispatcherMock.Object);

            _bookDispatchService.RouteToBookServicePost(request);

            _dispatcherMock.Verify(
                t => t.Dispatch <object, object>(It.IsAny <object>(), "https://1", null, HttpRequestCode.POST, null,
                                                 null), Times.Once);
        }
        public void RouteToBookServicePost(PostBookDispatcherRequest request)
        {
            var url = _bookServiceEndPoints.Value.Post;

            if (string.IsNullOrEmpty(url))
            {
                throw new InvalidOperationException(ErrorResources.EndpointIsNotValidOrEmpty);
            }

#pragma warning disable S1854 // Dead stores should be removed
            url = url.Replace("{userid}", request.UserId.ToString());
#pragma warning restore S1854 // Dead stores should be removed

            var restRequest = new
            {
                name       = request.Name, authorId = request.AuthorId, publisherId = request.PublisherId
                , tag      = request.Tag, no = request.No, publisherDate = request.PublisherDate
                , skinType = request.SkinType, libraryId = request.LibraryId
            };


            _dispatcher.Dispatch <object, object>(restRequest, url, null, HttpRequestCode.POST, null);
        }