public void Upload_Exception() { var fileName = Guid.NewGuid().ToString(); var auth = TestHelpers.AuthParamResponseFaker.Generate(); var imagekit = new ClientImagekit(GOOD_PUBLICKEY, GOOD_URLENDPOINT); var ex = Assert.ThrowsAsync <ArgumentException>(async() => await imagekit.UploadAsync("", auth)); Assert.Equal(Util.errorMessages.MISSING_UPLOAD_FILE_PARAMETER, ex.Result.Message); }
public async Task UploadAsync() { var fileName = Guid.NewGuid().ToString(); var fileUrl = "https://test.com/test.png"; var auth = TestHelpers.AuthParamResponseFaker.Generate(); 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, publicKey: GOOD_PUBLICKEY, clientAuth: auth)); Util.Utils.SetHttpClient(httpClient); var imagekit = new ClientImagekit(GOOD_PUBLICKEY, GOOD_URLENDPOINT) .FileName(fileName); var response = await imagekit.UploadAsync(fileUrl, auth); Assert.Equal(JsonConvert.SerializeObject(responseObj), JsonConvert.SerializeObject(response)); }