public void WhenOptionValueIsNull_ThrowInvalidObjectException() { _optionsMock.Setup(t => t.Value).Returns(() => new AuthorServiceEndPointConstants()); _service = new AuthorServiceDispatcher(null, _optionsMock.Object); Assert.Throws <InvalidOperationException>(() => _service.RouteToAuthorDelete("5c9f2f04f1d4914a40f7580c")); }
public void WhenAuthorServiceEndPointConstantsPost_IsNull_ThrowsInvalidOperationException() { _optionsMock.Setup(t => t.Value).Returns(() => new AuthorServiceEndPointConstants { Put = "" }); _service = new AuthorServiceDispatcher(_dispatcherMock.Object, _optionsMock.Object); Assert.Throws <InvalidOperationException>(() => _service.RouteToAuthorPut( It.IsAny <PutAuthorDispatcherRequest>())); }
public PutAuthorDispatcherTest() { _dispatcherMock = new Mock <IDispatcher>(); _optionsMock = new Mock <IOptions <AuthorServiceEndPointConstants> >(); _optionsMock.Setup(t => t.Value).Returns(() => new AuthorServiceEndPointConstants { Put = "http://api.authors.com/api/author" }); _service = new AuthorServiceDispatcher(_dispatcherMock.Object, _optionsMock.Object); }
public void WhenDispatchOperation_IsSuccessful_VerifyDispatchCalledOnce() { _optionsMock.Setup(t => t.Value).Returns(() => new AuthorServiceEndPointConstants { Delete = "http://api.com/delete" }); _service = new AuthorServiceDispatcher(_dispatcherMock.Object, _optionsMock.Object); _service.RouteToAuthorDelete("5c9f2f04f1d4914a40f7580c"); _dispatcherMock.Verify( t => t.Dispatch <object, object>(null, It.IsAny <string>(), null, HttpRequestCode.DELETE, null, null), Times.Once); }
public GetAuthorDispatcherTest() { var dispatcherMock = new Mock <IDispatcher>(); _optionsMock = new Mock <IOptions <AuthorServiceEndPointConstants> >(); _optionsMock.Setup(t => t.Value).Returns(() => new AuthorServiceEndPointConstants { Search = "http://api.authors.com/api/author/search", Get = "http://api.authors.com/api/author" }); dispatcherMock.Setup(t => t.Dispatch <object, GetAuthorDispatcherResponse>( null, It.IsAny <string>(), null, HttpRequestCode.GET, It.IsAny <Dictionary <string, object> >(), null)) .Returns(() => new GetAuthorDispatcherResponse { Total = 1, Authors = new List <AuthorModel> { new AuthorModel { Id = "id", Name = "name", Data = new AuthorModelMetaData { Dead = null, Birthday = Convert.ToDateTime("01.01.2019"), Books = null, ImageUrl = null, Location = null, Bio = "bio" } } } }); _sut = new AuthorServiceDispatcher(dispatcherMock.Object, _optionsMock.Object); }