public void Post_HttpReturnsFailResult_ThrowsException() { // Given var http = new Mock <IHttpChannel>(); http.Setup(h => h.Post(It.IsAny <IHttpRequest>(), It.IsAny <string>(), It.IsAny <string>())) .Returns(_failureResponse); var client = new ZendeskClient(new Uri("http://someurl.co.uk"), new ZendeskDefaultConfiguration("bob", "x1234//#"), _serializer.Object, http.Object); // When, Then Assert.Throws <HttpException>(() => client.Post <string>(new Uri("http://someurl.co.uk/resource"))); }
public void Post_Success_ReturnsSuccessResult() { // Given var http = new Mock <IHttpChannel>(); http.Setup(h => h.Post(It.IsAny <IHttpRequest>(), It.IsAny <string>(), It.IsAny <string>())) .Returns(_successResponse); var client = new ZendeskClient(new Uri("http://someurl.co.uk"), new ZendeskDefaultConfiguration("bob", "x1234//#"), _serializer.Object, http.Object); // When var result = client.Post <string>(new Uri("http://someurl.co.uk/resource")); // Then Assert.That(result, Is.EqualTo(_successResponse.Content)); }
public void Post_HttpReturnsFailResult_ThrowsException() { // Given var http = new Mock<IHttpChannel>(); http.Setup(h => h.Post(It.IsAny<IHttpRequest>())) .Returns(_failureResponse); var client = new ZendeskClient(new Uri("http://someurl.co.uk"), new ZendeskDefaultConfiguration("bob", "x1234//#"), _serializer.Object, http.Object); // When, Then Assert.Throws<HttpException>(() => client.Post<string>(new Uri("http://someurl.co.uk/resource"))); }
public void Post_Success_ReturnsSuccessResult() { // Given var http = new Mock<IHttpChannel>(); http.Setup(h => h.Post(It.IsAny<IHttpRequest>())) .Returns(_successResponse); var client = new ZendeskClient(new Uri("http://someurl.co.uk"), new ZendeskDefaultConfiguration("bob", "x1234//#"), _serializer.Object, http.Object); // When var result = client.Post<string>(new Uri("http://someurl.co.uk/resource")); // Then Assert.That(result, Is.EqualTo(_successResponse.Content)); }