public void Upload_Throws_IOException() { var fileName = Guid.NewGuid().ToString(); var fileUrl = @"c:\test\test.jpg"; var imagekit = new ServerImagekit(GOOD_PUBLICKEY, GOOD_PRIVATEKEY, GOOD_URLENDPOINT) .FileName(fileName); Exception ex = Assert.Throws <AggregateException>(() => imagekit.Upload(fileUrl)); Assert.Equal("File Not Found.", ex.InnerException.Message); }
public void Upload() { var fileName = Guid.NewGuid().ToString(); var fileUrl = "https://test.com/test.png"; var responseObj = TestHelpers.ImagekitResponseFaker.Generate(); var httpResponse = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(responseObj)) }; var httpClient = TestHelpers.GetTestHttpClient(httpResponse, TestHelpers.GetUploadRequestMessageValidator(fileUrl, fileName)); Util.Utils.SetHttpClient(httpClient); var imagekit = new ServerImagekit(GOOD_PUBLICKEY, GOOD_PRIVATEKEY, GOOD_URLENDPOINT) .FileName(fileName); var response = imagekit.Upload(fileUrl); Assert.Equal(JsonConvert.SerializeObject(responseObj), JsonConvert.SerializeObject(response)); }