summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChad Tolkien <chad@sodadigital.com.au>2016-10-05 17:32:18 +1100
committerChad Tolkien <chad@sodadigital.com.au>2016-10-05 17:32:18 +1100
commitfa4555b91a6be8bfdf58c9deb3b206aca23e96d6 (patch)
treeffacf15654012cb0f1c662e0b4bfade1d0951dba
parentbbe9b01c69d31f6c9bc23e653ca300aed41be427 (diff)
downloadTinyPNG-fa4555b91a6be8bfdf58c9deb3b206aca23e96d6.zip
TinyPNG-fa4555b91a6be8bfdf58c9deb3b206aca23e96d6.tar.gz
TinyPNG-fa4555b91a6be8bfdf58c9deb3b206aca23e96d6.tar.bz2
yet more tests
-rw-r--r--tests/TinyPng.Tests/TinyPngTests.cs50
1 files changed, 49 insertions, 1 deletions
diff --git a/tests/TinyPng.Tests/TinyPngTests.cs b/tests/TinyPng.Tests/TinyPngTests.cs
index 197dcfc..4c1f383 100644
--- a/tests/TinyPng.Tests/TinyPngTests.cs
+++ b/tests/TinyPng.Tests/TinyPngTests.cs
@@ -141,7 +141,41 @@ namespace TinyPng.Tests
}
[Fact]
- public async Task Resizing()
+ public async Task ResizingOperation()
+ {
+ var pngx = new TinyPngClient(apiKey);
+ pngx.httpClient = new HttpClient(new FakeResponseHandler()
+ .Compress()
+ .Resize());
+
+ var result = await pngx.Compress(Cat);
+
+ var resized = await pngx.Resize(result, 150, 150);
+
+ var resizedImageByteData = await resized.GetImageByteData();
+
+ Assert.Equal(5970, resizedImageByteData.Length);
+
+ }
+
+ [Fact]
+ public async Task ResizingOperationThrows()
+ {
+ var pngx = new TinyPngClient(apiKey);
+ pngx.httpClient = new HttpClient(new FakeResponseHandler()
+ .Compress()
+ .Resize());
+
+ var result = await pngx.Compress(Cat);
+
+ await Assert.ThrowsAsync<ArgumentNullException>(async () => await pngx.Resize(null, 150, 150));
+ await Assert.ThrowsAsync<ArgumentOutOfRangeException>(async () => await pngx.Resize(result, 0, 150));
+ await Assert.ThrowsAsync<ArgumentOutOfRangeException>(async () => await pngx.Resize(result, 150, 0));
+
+ }
+
+ [Fact]
+ public async Task ResizingScaleHeightOperation()
{
var pngx = new TinyPngClient(apiKey);
pngx.httpClient = new HttpClient(new FakeResponseHandler()
@@ -266,6 +300,20 @@ namespace TinyPng.Tests
}
[Fact]
+ public async Task CompressAndStoreToS3Throws()
+ {
+ var pngx = new TinyPngClient(apiKey);
+ pngx.httpClient = new HttpClient(new FakeResponseHandler()
+ .Compress()
+ .S3());
+
+ var result = await pngx.Compress(Cat);
+
+ await Assert.ThrowsAsync<ArgumentNullException>(async () => await pngx.SaveCompressedImageToAmazonS3(result, path: string.Empty));
+
+ }
+
+ [Fact]
public async Task CompressAndStoreToS3WithOptionsPassedIntoConstructor()
{
var pngx = new TinyPngClient(apiKey, new AmazonS3Configuration(ApiKey, ApiAccessKey, "tinypng-test-bucket", "ap-southeast-2"));