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