diff options
author | 杨宇千 <crupest@outlook.com> | 2019-08-19 01:44:29 +0800 |
---|---|---|
committer | 杨宇千 <crupest@outlook.com> | 2019-08-19 01:44:29 +0800 |
commit | 9a674f6f3a15ef260868049d945d7afc930f093c (patch) | |
tree | 6dd38c932babe4be032385f27ddff50645d48b38 /Timeline.Tests/Helpers | |
parent | cc646173d0667769c4f4ae78f51a626346d7e7ad (diff) | |
download | timeline-9a674f6f3a15ef260868049d945d7afc930f093c.tar.gz timeline-9a674f6f3a15ef260868049d945d7afc930f093c.tar.bz2 timeline-9a674f6f3a15ef260868049d945d7afc930f093c.zip |
Add integrated tests.
Diffstat (limited to 'Timeline.Tests/Helpers')
-rw-r--r-- | Timeline.Tests/Helpers/HttpClientExtensions.cs | 9 | ||||
-rw-r--r-- | Timeline.Tests/Helpers/ImageHelper.cs | 21 |
2 files changed, 30 insertions, 0 deletions
diff --git a/Timeline.Tests/Helpers/HttpClientExtensions.cs b/Timeline.Tests/Helpers/HttpClientExtensions.cs index cd40d91e..b9204fcc 100644 --- a/Timeline.Tests/Helpers/HttpClientExtensions.cs +++ b/Timeline.Tests/Helpers/HttpClientExtensions.cs @@ -1,5 +1,6 @@ using Newtonsoft.Json;
using System.Net.Http;
+using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
@@ -11,5 +12,13 @@ namespace Timeline.Tests.Helpers {
return client.PatchAsync(url, new StringContent(JsonConvert.SerializeObject(body), Encoding.UTF8, "application/json"));
}
+
+ public static Task<HttpResponseMessage> PutByteArrayAsync(this HttpClient client, string url, byte[] body, string mimeType)
+ {
+ var content = new ByteArrayContent(body);
+ content.Headers.ContentLength = body.Length;
+ content.Headers.ContentType = new MediaTypeHeaderValue(mimeType);
+ return client.PutAsync(url, content);
+ }
}
}
diff --git a/Timeline.Tests/Helpers/ImageHelper.cs b/Timeline.Tests/Helpers/ImageHelper.cs new file mode 100644 index 00000000..c5a9cf17 --- /dev/null +++ b/Timeline.Tests/Helpers/ImageHelper.cs @@ -0,0 +1,21 @@ +using SixLabors.ImageSharp;
+using SixLabors.ImageSharp.PixelFormats;
+using System.IO;
+
+namespace Timeline.Tests.Helpers
+{
+ public static class ImageHelper
+ {
+ public static byte[] CreatePngWithSize(int width, int height)
+ {
+ using (var image = new Image<Rgba32>(width, height))
+ {
+ using (var stream = new MemoryStream())
+ {
+ image.SaveAsPng(stream);
+ return stream.ToArray();
+ }
+ }
+ }
+ }
+}
|