示例#1
0
        public void WhenOptionValueIsNull_ThrowInvalidObjectException()
        {
            _optionsMock.Setup(t => t.Value).Returns(() => new PublisherServiceEndPointConstants());

            _service = new PublisherServiceDispatcher(null, _optionsMock.Object);
            Assert.Throws <InvalidOperationException>(() => _service.RouteToPublisherDelete("5c9f2f04f1d4914a40f7580c"));
        }
        public GetPublisherDispatcherTest()
        {
            var dispatcherMock = new Mock <IDispatcher>();

            _optionsMock = new Mock <IOptions <PublisherServiceEndPointConstants> >();

            _optionsMock.Setup(t => t.Value).Returns(() => new PublisherServiceEndPointConstants
            {
                Get = "http://api.publisher.com/api/publisher"
            });

            dispatcherMock.Setup(t =>
                                 t.Dispatch <object, GetPublisherDispatcherResponse>(
                                     null, It.IsAny <string>(), null, HttpRequestCode.GET,
                                     It.IsAny <Dictionary <string, object> >(), null))
            .Returns(() => new GetPublisherDispatcherResponse
            {
                Total      = 1,
                Publishers = new List <PublisherModel>()
                {
                    new PublisherModel()
                    {
                        Name   = "name",
                        Series = new List <string>()
                        {
                            "serie",
                            "serie"
                        }
                        , Id = "5c9f2f04f1d4914a40f7580c"
                    }
                }
            });

            _sut = new PublisherServiceDispatcher(dispatcherMock.Object, _optionsMock.Object);
        }
示例#3
0
        public void When_PublisherServiceEndPointConstantsPut_IsNull_ThrowsInvalidOperationException()
        {
            _optionsMock.Setup(t => t.Value).Returns(() => new PublisherServiceEndPointConstants {
                Put = ""
            });

            _service = new PublisherServiceDispatcher(_dispatcherMock.Object, _optionsMock.Object);

            Assert.Throws <InvalidOperationException>(() =>
                                                      _service.RouteToPublisherPut(
                                                          It.IsAny <PutPublisherDispatcherRequest>()));
        }
示例#4
0
        public PutPublisherDispatcherTest()
        {
            _dispatcherMock = new Mock <IDispatcher>();
            _optionsMock    = new Mock <IOptions <PublisherServiceEndPointConstants> >();

            _optionsMock.Setup(t => t.Value).Returns(() => new PublisherServiceEndPointConstants
            {
                Put = "http://api.authors.com/api/author"
            });

            _service = new PublisherServiceDispatcher(_dispatcherMock.Object, _optionsMock.Object);
        }
示例#5
0
        public void WhenDispatchOperation_IsSuccessful_VerifyDispatchCalledOnce()
        {
            _optionsMock.Setup(t => t.Value).Returns(() => new PublisherServiceEndPointConstants
            {
                Delete = "http://api.com/delete"
            });


            _service = new PublisherServiceDispatcher(_dispatcherMock.Object, _optionsMock.Object);

            _service.RouteToPublisherDelete("5c9f2f04f1d4914a40f7580c");

            _dispatcherMock.Verify(
                t => t.Dispatch <object, object>(null, It.IsAny <string>(), null, HttpRequestCode.DELETE, null, null),
                Times.Once);
        }