コード例 #1
0
 public void CannotBuildARequestWithAzureAndFtpSaveDestinations()
 {
     Assert.Throws <NotSupportedException>(() => BuildA.Request(r => r
                                                                .WithApplicationId("123")
                                                                .WithSourceImageUri(new Uri("http://www.foo.com/bar.gif"))
                                                                .Crop(f => f.WithDimensions(1, 2, 3, 4)
                                                                      .SaveAs(s => s.WithImageIdentifier("image")
                                                                              .WithExtension(Extension.PNG)
                                                                              .WithQuality(10)
                                                                              .ToAzure(a => a
                                                                                       .WithAccountName("azureAccount")
                                                                                       .WithSharedAccessSignature("sharedkey"))
                                                                              .ToFtp(a => a
                                                                                     .WithDirectory("directory")
                                                                                     .WithFileName("filename")
                                                                                     .WithPassword("password")
                                                                                     .WithServer("server")
                                                                                     .WithUser("user"))))));
 }
コード例 #2
0
        public void CanBuildAnAppendFunction()
        {
            BlitlineRequest request = default(BlitlineRequest);

            "When I build an photograph function".Context(() => request = BuildA.Request(r => r
                                                                                         .WithApplicationId("123")
                                                                                         .WithSourceImageUri(new Uri("http://foo.bar.gif"))
                                                                                         .Photograph(f => f.WithAngle(2))));

            "Then the name should be photograph".Observation(() => Assert.Equal("photograph", request.Functions[0].Name));
            "And the angle should be 2".Observation(() => Assert.Equal(2, ((PhotographFunction)request.Functions[0]).Angle));

            "And the params should be constructed".Observation(() =>
            {
                var p = request.Functions[0].Params;
                var t = p.GetType();
                Assert.Equal(2, (int)t.GetProperty("angle").GetValue(p, null));
            });
        }
コード例 #3
0
 public void CannotBuildARequestWithS3AndAzureSaveDestinations()
 {
     Assert.Throws <NotSupportedException>(() => BuildA.Request(r => r
                                                                .WithApplicationId("123")
                                                                .WithSourceImageUri(new Uri("http://www.foo.com/bar.gif"))
                                                                .Crop(f => f.WithDimensions(1, 2, 3, 4)
                                                                      .SaveAs(s => s.WithImageIdentifier("image")
                                                                              .WithExtension(Extension.PNG)
                                                                              .WithQuality(10)
                                                                              .ToS3(s3 => s3.ToBucket("Bucket")
                                                                                    .WithKey("Key")
                                                                                    .WithHeader("1", "foo")
                                                                                    .WithHeaders(new Dictionary <string, string> {
         { "2", "bar" }
     }))
                                                                              .ToAzure(a => a
                                                                                       .WithAccountName("azureAccount")
                                                                                       .WithSharedAccessSignature("sharedkey"))))));
 }
コード例 #4
0
        public void CanBuildAnAppendFunction()
        {
            BlitlineRequest request = default(BlitlineRequest);

            "When I build an append function".Context(() => request = BuildA.Request(r => r
                                                                                     .WithApplicationId("123")
                                                                                     .WithSourceImageUri(new Uri("http://foo.bar.gif"))
                                                                                     .Append(f => f.AppendVeritically(true))));

            "Then the name should be append".Observation(() => Assert.Equal("append", request.Functions[0].Name));
            "And the vertical should be true".Observation(() => Assert.Equal(true, ((AppendFunction)request.Functions[0]).Vertical));

            "And the params should be constructed".Observation(() =>
            {
                var p = request.Functions[0].Params;
                var t = p.GetType();
                Assert.Equal(true, (bool)t.GetProperty("vertical").GetValue(p, null));
            });
        }
コード例 #5
0
        public async void CanProcessAnnotationFunctionAsync()
        {
            const string bucketName = "gdoubleu-test-photos";

            var request = BuildA.Request(r => r
                                         .WithApplicationId("a5KqkemeX2RttyYdkOrdug")
                                         .WithSourceImageUri(
                                             new Uri("https://s3-eu-west-1.amazonaws.com/gdoubleu-test-photos/moi.jpg"))
                                         .Annotate(f => f.WithText("Hello")
                                                   .SaveAs(s => s.WithImageIdentifier("image_identifier")
                                                           .ToS3(s3 => s3
                                                                 .ToBucket(bucketName)
                                                                 .WithKey("annotate-default.png")))));

            var task = request.SendAsync();

            var foo = await task;

            Console.WriteLine(foo.Results.JobId);
        }
コード例 #6
0
        public void CanBuildAMedianFilterFunction()
        {
            BlitlineRequest request = default(BlitlineRequest);

            "When I build a median filter function".Context(() => request = BuildA.Request(r => r
                                                                                           .WithApplicationId("123")
                                                                                           .WithSourceImageUri(new Uri("http://foo.bar.gif"))
                                                                                           .MedianFilter(f => f.WithRadius(2m))));

            "Then the name should be median_filter".Observation(() => Assert.Equal("median_filter", request.Functions[0].Name));
            "And the radius should be 2".Observation(() => Assert.Equal(2, ((MedianFilterFunction)request.Functions[0]).Radius));

            "And the params should be constructed".Observation(() =>
            {
                var p = request.Functions[0].Params;
                var t = p.GetType();

                Assert.Equal(2m, (decimal)t.GetProperty("radius").GetValue(p, null));
            });
        }
コード例 #7
0
        public void CanBuildARequestWithoutSourceType()
        {
            BlitlineRequest request = default(BlitlineRequest);

            "When I build a request without source type".Context(() => request = BuildA.Request(r => r
                                                                                                .WithApplicationId("123")
                                                                                                .WithSourceImageUri(new Uri("http://www.foo.com/bar.gif"))
                                                                                                .Crop(f => f.WithDimensions(1, 2, 3, 4)
                                                                                                      .SaveAs(s => s.WithImageIdentifier("image")
                                                                                                              .WithExtension(Extension.PNG)
                                                                                                              .WithQuality(10)
                                                                                                              .ToS3(s3 => s3.ToBucket("Bucket")
                                                                                                                    .WithKey("Key")
                                                                                                                    .WithHeader("1", "foo")
                                                                                                                    .WithHeaders(new Dictionary <string, string> {
                { "2", "bar" }
            }))))));

            "Then source type is null".Observation(() => Assert.Null(request.SourceType));
        }
コード例 #8
0
        public void CanBuildAnAnnotateFunction()
        {
            BlitlineRequest request = default(BlitlineRequest);

            "When I build an annotate function".Context(() => request = BuildA.Request(r => r
                                                                                       .WithApplicationId("123")
                                                                                       .WithSourceImageUri(new Uri("http://foo.bar.gif"))
                                                                                       .Annotate(f => f
                                                                                                 .WithText("Text")
                                                                                                 .WithPosition(1, 1)
                                                                                                 .WithColour("ccc")
                                                                                                 .WithFontFamilty("Arial")
                                                                                                 .WithPointSize(10)
                                                                                                 .WithStroke("super")
                                                                                                 .WithGravity(Gravity.NorthGravity))));

            "The the name should be annotate".Observation(() => Assert.Equal("annotate", request.Functions[0].Name));
            "And the text should be set".Observation(() => Assert.Equal("Text", ((AnnotateFunction)request.Functions[0]).Text));
            "And the x should be 1".Observation(() => Assert.Equal(1, ((AnnotateFunction)request.Functions[0]).X));
            "And the y should be 1".Observation(() => Assert.Equal(1, ((AnnotateFunction)request.Functions[0]).Y));
            "And the colour should be ccc".Observation(() => Assert.Equal("ccc", ((AnnotateFunction)request.Functions[0]).Colour));
            "And the font family should be Arial".Observation(() => Assert.Equal("Arial", ((AnnotateFunction)request.Functions[0]).FontFamily));
            "And the point size should be 10".Observation(() => Assert.Equal(10, ((AnnotateFunction)request.Functions[0]).PointSize));
            "And the stroke should be super".Observation(() => Assert.Equal("super", ((AnnotateFunction)request.Functions[0]).Stroke));
            "And the gravity should be NorthGravity".Observation(() => Assert.Equal(Gravity.NorthGravity, ((AnnotateFunction)request.Functions[0]).Gravity));

            "And the params should be constructed".Observation(() =>
            {
                var p = request.Functions[0].Params;
                var t = p.GetType();
                Assert.Equal("Text", t.GetProperty("text").GetValue(p, null).ToString());
                Assert.Equal(1, (int)t.GetProperty("x").GetValue(p, null));
                Assert.Equal(1, (int)t.GetProperty("y").GetValue(p, null));
                Assert.Equal("ccc", t.GetProperty("color").GetValue(p, null).ToString());
                Assert.Equal("Arial", t.GetProperty("font_family").GetValue(p, null).ToString());
                Assert.Equal(10, (int)t.GetProperty("point_size").GetValue(p, null));
                Assert.Equal("super", t.GetProperty("stroke").GetValue(p, null).ToString());
                Assert.Equal("NorthGravity", t.GetProperty("gravity").GetValue(p, null).ToString());
            });
        }
コード例 #9
0
        public void CanBuildARequest()
        {
            BlitlineRequest request = default(BlitlineRequest);

            "When I build a request".Context(() => request = BuildA.Request(r => r
                                                                            .WithApplicationId("123")
                                                                            .FixS3ImageUrl()
                                                                            .WaitForS3()
                                                                            .ContentTypeAsJson()
                                                                            .SuppressAutoOrientation()
                                                                            .WithPostbackUri(new Uri("http://www.bar.com/"))
                                                                            .WithExtendedMetaData()
                                                                            .WithHash(Hash.Md5)
                                                                            .WithSourceImageUri(new Uri("http://www.foo.com/bar.gif"))
                                                                            .SourceIsScreenshot()
                                                                            .Crop(f => f.WithDimensions(1, 2, 3, 4))));

            "Then the request is not null".Observation(() => Assert.NotNull(request));

            "And the application id is 123".Observation(() => Assert.Equal("123", request.ApplicationId));

            "And the source image is http://www.foo.com/bar.gif".Observation(() => Assert.Equal("http://www.foo.com/bar.gif", request.SourceImage));

            "And wait for s3 is true".Observation(() => Assert.Equal(true, request.WaitForS3));

            "And content type as json is true".Observation(() => Assert.True(request.ContentTypeJson));

            "And supress auto orientation is true".Observation(() => Assert.True(request.SuppressAutoOrient));

            "And the postback url is http://postback.com".Observation(() => Assert.Equal("http://www.bar.com/", request.PostbackUrl));

            "And extended meta data is true".Observation(() => Assert.True(request.ExtendedMetaData));

            "And the hash is Md5".Observation(() => Assert.Equal(Hash.Md5, request.Hash));

            "And the source type is screen_shot_url".Observation(() => Assert.Equal("screen_shot_url", request.SourceType));

            "And there is 1 function".Observation(() => Assert.Equal(1, request.Functions.Count));
        }
コード例 #10
0
 public void CannotBuildARequestWithS3AndFtpSaveDestinations()
 {
     Assert.Throws <NotSupportedException>(() => BuildA.Request(r => r
                                                                .WithApplicationId("123")
                                                                .WithSourceImageUri(new Uri("http://www.foo.com/bar.gif"))
                                                                .Crop(f => f.WithDimensions(1, 2, 3, 4)
                                                                      .SaveAs(s => s.WithImageIdentifier("image")
                                                                              .WithExtension(Extension.PNG)
                                                                              .WithQuality(10)
                                                                              .ToS3(s3 => s3.ToBucket("Bucket")
                                                                                    .WithKey("Key")
                                                                                    .WithHeader("1", "foo")
                                                                                    .WithHeaders(new Dictionary <string, string> {
         { "2", "bar" }
     }))
                                                                              .ToFtp(a => a
                                                                                     .WithDirectory("directory")
                                                                                     .WithFileName("filename")
                                                                                     .WithPassword("password")
                                                                                     .WithServer("server")
                                                                                     .WithUser("user"))))));
 }
コード例 #11
0
        public void CanBuildAScaleFunctionWithOnlyWidthAndHeight()
        {
            BlitlineRequest request = default(BlitlineRequest);

            "When I build a scale function".Context(() => request = BuildA.Request(r => r
                                                                                   .WithApplicationId("123")
                                                                                   .WithSourceImageUri(new Uri("http://foo.bar.gif"))
                                                                                   .Scale(f => f.WithWidth(5).WithHeight(2))));

            "Then the name should be scale".Observation(() => Assert.Equal("scale", request.Functions[0].Name));
            "And the width should be 5".Observation(() => Assert.Equal(5, ((ScaleFunction)request.Functions[0]).Width));
            "And the height should be 2".Observation(() => Assert.Equal(2, ((ScaleFunction)request.Functions[0]).Height));
            "And the scale factor should be 0".Observation(() => Assert.Equal(0m, ((ScaleFunction)request.Functions[0]).ScaleFactor));

            "And the params should be constructed".Observation(() =>
            {
                var p = request.Functions[0].Params;

                Assert.Equal(5, p.width);
                Assert.Equal(2, p.height);
            });
        }
コード例 #12
0
        public void CanBuildAResizeFunctionWithOnlyAScaleFactor()
        {
            BlitlineRequest request = default(BlitlineRequest);

            "When I build a resize function".Context(() => request = BuildA.Request(r => r
                                                                                    .WithApplicationId("123")
                                                                                    .WithSourceImageUri(new Uri("http://foo.bar.gif"))
                                                                                    .Resize(f => f.WithScaleFactor(0.2m))));

            "Then the name should be resize".Observation(() => Assert.Equal("resize", request.Functions[0].Name));
            "And the width should be 0".Observation(() => Assert.Equal(0, ((ResizeFunction)request.Functions[0]).Width));
            "And the height should be 0".Observation(() => Assert.Equal(0, ((ResizeFunction)request.Functions[0]).Height));
            "And the scale factor should be 0.2".Observation(() => Assert.Equal(0.2m, ((ResizeFunction)request.Functions[0]).ScaleFactor));

            "And the params should be constructed".Observation(() =>
            {
                var p = request.Functions[0].Params;
                Assert.Equal(0, p.width);
                Assert.Equal(0, p.height);
                Assert.Equal(0.2m, p.scale_factor);
            });
        }
コード例 #13
0
        public void CanProcessAMultipageDocumentWithSpecificPages()
        {
            var request  = default(BlitlineRequest);
            var response = default(BlitlineResponse);

            "Given I have a screenshot request".Context(() =>
            {
                const string bucketName = "gdoubleu-test-photos";

                request = BuildA.Request(r => r
                                         .WithApplicationId("a5KqkemeX2RttyYdkOrdug")
                                         .WithSourceImageUri(new Uri("https://s3-eu-west-1.amazonaws.com/gdoubleu-test-photos/Gareth+Williams%27s+Resume.pdf"))
                                         .SourceIsMultipageDocument(new[] { 1 })
                                         .ResizeToFit(f => f.WithWidth(200).WithHeight(200)
                                                      .SaveAs(s => s.WithImageIdentifier("multipage_2")
                                                              .ToS3(s3 => s3.ToBucket(bucketName).WithKey("multipage_page.png")))));
            });

            "When I process the request".Do(() => response = request.Send());

            "Then the s3 url should not be empty".Observation(() => Assert.NotEmpty(response.Results.Images.First().S3Url));
        }
コード例 #14
0
        public void CanProcessAScaleFunctionWithJustHeightAndWidth()
        {
            var request  = default(BlitlineRequest);
            var response = default(BlitlineResponse);

            "Given I have a scale function with only a scale factor".Context(() =>
            {
                const string bucketName = "gdoubleu-test-photos";

                request = BuildA.Request(r => r
                                         .WithApplicationId("a5KqkemeX2RttyYdkOrdug")
                                         .WithSourceImageUri(new Uri("https://s3-eu-west-1.amazonaws.com/gdoubleu-test-photos/moi.jpg"))
                                         .Scale(f => f.WithHeight(50).WithWidth(100)
                                                .SaveAs(s => s.WithImageIdentifier("image_identifier")
                                                        .ToS3(s3 => s3
                                                              .ToBucket(bucketName)
                                                              .WithKey("moi-scale-heightwidth.png")))));
            });

            "When I process the request".Do(() => response = request.Send());

            "Then the s3 url should not be empty".Observation(() => Assert.NotEmpty(response.Results.Images.First().S3Url));
        }
コード例 #15
0
        public void CanBuildARequestWithAnAzureDestination()
        {
            BlitlineRequest request = default(BlitlineRequest);

            "When I build a request".Context(() => request = BuildA.Request(r => r
                                                                            .WithApplicationId("123")
                                                                            .WithSourceImageUri(new Uri("http://www.foo.com/bar.gif"))
                                                                            .Crop(c => c.WithDimensions(1, 2, 3, 4)
                                                                                  .SaveAs(s => s.WithImageIdentifier("image")
                                                                                          .WithExtension(Extension.PNG)
                                                                                          .WithQuality(10)
                                                                                          .ToAzure(f => f.WithAccountName("azureaccount")
                                                                                                   .WithSharedAccessSignature("sharedaccesssignature")
                                                                                                   )
                                                                                          )
                                                                                  )));

            "Then save contains an azure destination".Observation(() => Assert.NotNull(request.Functions.First().Save.AzureDestination));

            "And the account name should be azureaccount".Observation(() => Assert.Equal("azureaccount", request.Functions.First().Save.AzureDestination.AccountName));

            "And the shared access signature should be sharedaccesssignature".Observation(() => Assert.Equal("sharedaccesssignature", request.Functions.First().Save.AzureDestination.SharedAccessSignature));
        }
コード例 #16
0
        public void CanBuildAQuantizeFunctionWithOnlyRequiredValues()
        {
            BlitlineRequest request = default(BlitlineRequest);

            "When I build a quantize function".Context(() => request = BuildA.Request(r => r
                                                                                      .WithApplicationId("123")
                                                                                      .WithSourceImageUri(new Uri("http://foo.bar.gif"))
                                                                                      .Quantize(f => f.WithNumberOfColours(5))));

            "Then the name should be quantize".Observation(() => Assert.Equal("quantize", request.Functions[0].Name));
            "And the number of colours should be 5".Observation(() => Assert.Equal(5, ((QuantizeFunction)request.Functions[0]).NumberOfColours));
            "And the colour space should be colours".Observation(() => Assert.Equal("RGBColorspace", ((QuantizeFunction)request.Functions[0]).ColourSpace));
            "And the the dither should be false".Observation(() => Assert.Equal(false, ((QuantizeFunction)request.Functions[0]).Dither));

            "And the params should be constructed".Observation(() =>
            {
                var p = request.Functions[0].Params;
                var t = p.GetType();

                Assert.Equal(5, (int)t.GetProperty("number_colors").GetValue(p, null));
                Assert.Equal("RGBColorspace", t.GetProperty("color_space").GetValue(p, null).ToString());
                Assert.Equal(false, (bool)t.GetProperty("dither").GetValue(p, null));
            });
        }
コード例 #17
0
        public void CanBuildASketchFunction()
        {
            BlitlineRequest request = default(BlitlineRequest);

            "When I build a sketch function".Context(() => request = BuildA.Request(r => r
                                                                                    .WithApplicationId("123")
                                                                                    .WithSourceImageUri(new Uri("http://foo.bar.gif"))
                                                                                    .Sketch(f => f.WithSigma(5m).WithRadius(2m).WithAngle(2m))));

            "Then the name should be sketch".Observation(() => Assert.Equal("sketch", request.Functions[0].Name));
            "And the sigma should be 5".Observation(() => Assert.Equal(5m, ((SketchFunction)request.Functions[0]).Sigma));
            "And the radius should be 2".Observation(() => Assert.Equal(2m, ((SketchFunction)request.Functions[0]).Radius));
            "And the angle should be 2".Observation(() => Assert.Equal(2m, ((SketchFunction)request.Functions[0]).Angle));

            "And the params should be constructed".Observation(() =>
            {
                var p = request.Functions[0].Params;
                var t = p.GetType();

                Assert.Equal(5m, (decimal)t.GetProperty("sigma").GetValue(p, null));
                Assert.Equal(2m, (decimal)t.GetProperty("radius").GetValue(p, null));
                Assert.Equal(2m, (decimal)t.GetProperty("angle").GetValue(p, null));
            });
        }
コード例 #18
0
        public void CanBuildAModulateFunction()
        {
            BlitlineRequest request = default(BlitlineRequest);

            "When I build a modulate function".Context(() => request = BuildA.Request(r => r
                                                                                      .WithApplicationId("123")
                                                                                      .WithSourceImageUri(new Uri("http://foo.bar.gif"))
                                                                                      .Modulate(f => f.WithBrightness(2m).WithSaturation(2.0m).WithHue(2.0m))));

            "Then the name should be modulate".Observation(() => Assert.Equal("modulate", request.Functions[0].Name));
            "And the brightness should be 2".Observation(() => Assert.Equal(2.0m, ((ModulateFunction)request.Functions[0]).Brightness));
            "And the saturation should be 2".Observation(() => Assert.Equal(2.0m, ((ModulateFunction)request.Functions[0]).Saturation));
            "And the hue should be 2".Observation(() => Assert.Equal(2.0m, ((ModulateFunction)request.Functions[0]).Hue));

            "And the params should be constructed".Observation(() =>
            {
                var p = request.Functions[0].Params;
                var t = p.GetType();

                Assert.Equal(2.0m, (decimal)t.GetProperty("brightness").GetValue(p, null));
                Assert.Equal(2.0m, (decimal)t.GetProperty("saturation").GetValue(p, null));
                Assert.Equal(2.0m, (decimal)t.GetProperty("hue").GetValue(p, null));
            });
        }
コード例 #19
0
        public void CanBuildARequestWithSaveData()
        {
            BlitlineRequest request = default(BlitlineRequest);

            "When I build a request".Context(() => request = BuildA.Request(r => r
                                                                            .WithApplicationId("123")
                                                                            .WithSourceImageUri(new Uri("http://www.foo.com/bar.gif"))
                                                                            .Crop(f => f.WithDimensions(1, 2, 3, 4)
                                                                                  .SaveAs(s => s.WithImageIdentifier("image")
                                                                                          .WithExtension(Extension.PNG)
                                                                                          .WithQuality(10)
                                                                                          .QuantizePng()
                                                                                          .WithInterlaceType(InterlaceType.LineInterlace)))));

            "Then the function has a save value".Observation(() => Assert.NotNull(request.Functions.First().Save));

            "And the image identifier is image".Observation(() => Assert.Equal("image", request.Functions.First().Save.ImageIdentifier));

            "And the quality is 10".Observation(() => Assert.Equal(10, request.Functions.First().Save.Quality));

            "And quantize png is true".Observation(() => Assert.True(request.Functions[0].Save.PngQuantize));

            "And the interlace type is LineInterlace".Observation(() => Assert.Equal("LineInterlace", request.Functions[0].Save.Interlace));
        }
コード例 #20
0
        public void CanProcessAScreenShot()
        {
            var request  = default(BlitlineRequest);
            var response = default(BlitlineResponse);

            "Given I have a screenshot request".Context(() =>
            {
                const string bucketName = "gdoubleu-test-photos";

                request = BuildA.Request(r => r
                                         .WithApplicationId("a5KqkemeX2RttyYdkOrdug")
                                         .WithSourceImageUri(new Uri("http://www.google.co.uk"))
                                         .SourceIsScreenshot()
                                         .Crop(f => f.WithDimensions(51, 126, 457 - 126, 382 - 51)
                                               .SaveAs(s => s.WithImageIdentifier("image_identifier")
                                                       .ToS3(s3 => s3
                                                             .ToBucket(bucketName)
                                                             .WithKey("screenshot.png")))));
            });

            "When I process the request".Do(() => response = request.Send());

            "Then the s3 url should not be empty".Observation(() => Assert.NotEmpty(response.Results.Images.First().S3Url));
        }
コード例 #21
0
        public void CanBuildAModulateWithOnlyRequiredValues()
        {
            BlitlineRequest request = default(BlitlineRequest);

            "When I build a median pad resize to fit function".Context(() => request = BuildA.Request(r => r
                                                                                                      .WithApplicationId("123")
                                                                                                      .WithSourceImageUri(new Uri("http://foo.bar.gif"))
                                                                                                      .PadResizeToFit(f => f.WithWidth(2).WithHeight(2))));

            "Then the name should be pad_resize_to_fit".Observation(() => Assert.Equal("pad_resize_to_fit", request.Functions[0].Name));
            "And the width should be 2".Observation(() => Assert.Equal(2, ((PadResizeToFitFunction)request.Functions[0]).Width));
            "And the height should be 2".Observation(() => Assert.Equal(2, ((PadResizeToFitFunction)request.Functions[0]).Height));
            "And the hue should be #ffffff".Observation(() => Assert.Equal("#ffffff", ((PadResizeToFitFunction)request.Functions[0]).Colour));
            "And the gravity should be CenterGrativty".Observation(() => Assert.Equal(Gravity.CenterGrativty, ((PadResizeToFitFunction)request.Functions[0]).Gravity));

            "And the params should be constructed".Observation(() =>
            {
                var p = request.Functions[0].Params;
                var t = p.GetType();

                Assert.Equal(2, (int)t.GetProperty("width").GetValue(p, null));
                Assert.Equal(2, (int)t.GetProperty("height").GetValue(p, null));
                Assert.Equal("#ffffff", t.GetProperty("color").GetValue(p, null).ToString());
                Assert.Equal("CenterGrativty", t.GetProperty("gravity").GetValue(p, null).ToString());
            });
        }
コード例 #22
0
        public void CanBuildAContrastStretchChannelFunction()
        {
            BlitlineRequest request = default(BlitlineRequest);

            "When I build an contrast stretch channel function".Context(() => request = BuildA.Request(r => r
                                                                                                       .WithApplicationId("123")
                                                                                                       .WithSourceImageUri(new Uri("http://foo.bar.gif"))
                                                                                                       .ContrastStretchChannel(f => f.WithBlackPoint(10)
                                                                                                                               .WithWhitePoint(5))));

            "Then the name should be contrast_stretch_channel".Observation(() => Assert.Equal("contrast_stretch_channel", request.Functions[0].Name));
            "And the black point should be 10".Observation(() => Assert.Equal(10, ((ContrastStretchChannelFunction)request.Functions[0]).BlackPoint));
            "And the white point should be 5".Observation(() => Assert.Equal(5, ((ContrastStretchChannelFunction)request.Functions[0]).WhitePoint));

            "And the params should be constructed".Observation(() =>
            {
                var p = request.Functions[0].Params;
                var t = p.GetType();
                Assert.Equal(10, (int)t.GetProperty("black_point").GetValue(p, null));
                Assert.Equal(5, (int)t.GetProperty("white_point").GetValue(p, null));
            });
        }
コード例 #23
0
        public void CanBuildAResizeToFitFunction()
        {
            BlitlineRequest request = default(BlitlineRequest);

            "When I build a resize to resize_to_fit function".Context(() => request = BuildA.Request(r => r
                                                                                                     .WithApplicationId("123")
                                                                                                     .WithSourceImageUri(new Uri("http://foo.bar.gif"))
                                                                                                     .ResizeToFit(f => f.WithWidth(5).WithHeight(2)
                                                                                                                  .OnlyShrinkLarger(true))));

            "Then the name should be resize_to_fit".Observation(() => Assert.Equal("resize_to_fit", request.Functions[0].Name));
            "And the width should be 5".Observation(() => Assert.Equal(5, ((ResizeToFitFunction)request.Functions[0]).Width));
            "And the height should be 2".Observation(() => Assert.Equal(2, ((ResizeToFitFunction)request.Functions[0]).Height));
            "And the only shrink larger be true".Observation(() => Assert.Equal(true, ((ResizeToFitFunction)request.Functions[0]).OnlyShrinkLarger));

            "And the params should be constructed".Observation(() =>
            {
                var p = request.Functions[0].Params;
                var t = p.GetType();

                Assert.Equal(5, (int)t.GetProperty("width").GetValue(p, null));
                Assert.Equal(2, (int)t.GetProperty("height").GetValue(p, null));
                Assert.Equal(true, (bool)t.GetProperty("only_shrink_larger").GetValue(p, null));
            });
        }
コード例 #24
0
        public void CanBuildAMultipageWithSpecificPagesRequest()
        {
            BlitlineRequest request = default(BlitlineRequest);

            "When I build a multipage with page numbers request".Context(() => request = BuildA.Request(r => r
                                                                                                        .WithApplicationId("123")
                                                                                                        .WithSourceImageUri(new Uri("http://www.foo.com/bar.gif"))
                                                                                                        .SourceIsMultipageDocument(new[] { 1, 3 })
                                                                                                        .Crop(f => f.WithDimensions(1, 2, 3, 4)
                                                                                                              .SaveAs(s => s.WithImageIdentifier("image")
                                                                                                                      .WithExtension(Extension.PNG)
                                                                                                                      .WithQuality(10)
                                                                                                                      .ToS3(s3 => s3.ToBucket("Bucket")
                                                                                                                            .WithKey("Key")
                                                                                                                            .WithHeader("1", "foo")
                                                                                                                            .WithHeaders(new Dictionary <string, string> {
                { "2", "bar" }
            }))))));

            "Then source type is multipage".Observation(() => Assert.Equal("multi_page", request.SourceType.Name));

            "And there are 2 pages".Observation(() => Assert.Equal(2, request.SourceType.Pages.Length));

            "And the 1st page is 1".Observation(() => Assert.Equal(1, request.SourceType.Pages[0]));

            "And the 1st page is 3".Observation(() => Assert.Equal(3, request.SourceType.Pages[1]));
        }