public static FakeResponseHandler Compress(this FakeResponseHandler fakeResponse) { var content = new TinyPngApiResult(); content.Input = new TinyPngApiInput { Size = 18031, Type = "image/jpeg" }; content.Output = new TinyPngApiOutput { Width = 400, Height = 400, Size = 16646, Type = "image/jpeg", Ratio = 0.9232f, Url = "https://api.tinify.com/output" }; var compressResponseMessage = new HttpResponseMessage { StatusCode = System.Net.HttpStatusCode.Created, Content = new StringContent(JsonConvert.SerializeObject(content)), }; compressResponseMessage.Headers.Location = new Uri("https://api.tinify.com/output"); compressResponseMessage.Headers.Add("Compression-Count", "99"); fakeResponse.AddFakePostResponse(new Uri("https://api.tinify.com/shrink"), compressResponseMessage); return fakeResponse; }
public static FakeResponseHandler S3(this FakeResponseHandler fakeResponse) { var amazonMessage = new HttpResponseMessage { StatusCode = System.Net.HttpStatusCode.OK }; amazonMessage.Headers.Add("Location", "https://s3-ap-southeast-2.amazonaws.com/tinypng-test-bucket/path.jpg"); fakeResponse.AddFakePostResponse(new Uri("https://api.tinify.com/output"), amazonMessage); return fakeResponse; }
public static FakeResponseHandler Resize(this FakeResponseHandler fakeResponse) { var resizedCatStream = File.OpenRead(TinyPngTests.ResizedCat); var resizeMessage = new HttpResponseMessage { StatusCode = System.Net.HttpStatusCode.OK, Content = new StreamContent(resizedCatStream) }; resizeMessage.Headers.Add("Image-Width", "150"); resizeMessage.Headers.Add("Image-Height", "150"); fakeResponse.AddFakePostResponse(new Uri("https://api.tinify.com/output"), resizeMessage); return fakeResponse; }