Exemplo n.º 1
0
        public void WhenRouteToBookServicePut_DispatchReturnsSuccess()
        {
            var request = new PutBookDispatcherRequest
            {
                UserId      = 1, No = 5, Name = "aaa", Tag = "tag", ShelfId = 1, AuthorId = "id", SkinType = 1
                , LibraryId = "id", PublisherId = 1, PublisherDate = Convert.ToDateTime("01.01.2019"), Id = 1
            };

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

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

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

            _bookDispatchService.RouteToBookServicePut(request);

            _dispatcherMock.Verify(
                t => t.Dispatch <object, object>(It.IsAny <object>(), "https://1", null, HttpRequestCode.PUT, null, null),
                Times.Once);
        }
Exemplo n.º 2
0
        public void WhenRouteToBookServicePut_ThrowsInvalidOperationException()
        {
            _bookServiceEndPointsMock.Setup(t => t.Value)
            .Returns(() => new BookServiceEndPointConstants {
                Put = string.Empty
            });

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

            Assert.Throws <InvalidOperationException>(() =>
                                                      _bookDispatchService.RouteToBookServicePut(
                                                          new PutBookDispatcherRequest()));
        }