public void CanBuildAnUnsharpMaskFunction() { BlitlineRequest request = default(BlitlineRequest); "When I build a unsharp mask function".Context(() => request = BuildA.Request(r => r .WithApplicationId("123") .WithSourceImageUri(new Uri("http://foo.bar.gif")) .UnsharpMask(f => f.WithSigma(5m).WithRadius(4m).WithAmount(0.3m).WithThreshold(0.2m)))); "Then the name should be unsharp_mask".Observation(() => Assert.Equal("unsharp_mask", request.Functions[0].Name)); "And the sigma should be 5".Observation(() => Assert.Equal(5m, ((UnsharpMaskFunction)request.Functions[0]).Sigma)); "And the radius should be 4".Observation(() => Assert.Equal(4m, ((UnsharpMaskFunction)request.Functions[0]).Radius)); "And the amount should be 0.3".Observation(() => Assert.Equal(0.3m, ((UnsharpMaskFunction)request.Functions[0]).Amount)); "And the threshold should be 0.2".Observation(() => Assert.Equal(0.2m, ((UnsharpMaskFunction)request.Functions[0]).Threshold)); "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(4m, (decimal)t.GetProperty("radius").GetValue(p, null)); Assert.Equal(0.3m, (decimal)t.GetProperty("amount").GetValue(p, null)); Assert.Equal(0.2m, (decimal)t.GetProperty("threshold").GetValue(p, null)); }); }
public void CanSaveToS3BucketAndFixUrl() { var request = default(BlitlineRequest); var response = default(BlitlineResponse); const string bucketName = "gdoubleu-test-photos"; "Given I have a blitline request with an s3 destination".Context(() => { request = BuildA.Request(r => r .WithApplicationId("a5KqkemeX2RttyYdkOrdug") .WithSourceImageUri(new Uri("https://s3-eu-west-1.amazonaws.com/gdoubleu-test-photos/moi.jpg")) .FixS3ImageUrl() .Crop(f => f.WithDimensions(51, 126, 457 - 126, 382 - 51) .SaveAs(s => s.WithImageIdentifier("image_identifier") .ToS3(s3 => s3 .ToBucket(bucketName) .WithKey("moi-correct-url.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)); "And the s3 url should be correct".Observation(() => Assert.Equal("http://gdoubleu-test-photos.s3.amazonaws.com/moi-correct-url.png", response.Results.Images.First().S3Url)); }
public void CanBuildAWatermarkFunctionWithOnlyRequiredValues() { BlitlineRequest request = default(BlitlineRequest); "When I build a watermark function".Context(() => request = BuildA.Request(r => r .WithApplicationId("123") .WithSourceImageUri(new Uri("http://foo.bar.gif")) .Watermark(f => f.WithText("text")))); "Then the name should be watermark".Observation(() => Assert.Equal("watermark", request.Functions[0].Name)); "And the text should be text".Observation(() => Assert.Equal("text", ((WatermarkFunction)request.Functions[0]).Text)); "And the gravity should be CenterGrativty".Observation(() => Assert.Equal(Gravity.CenterGrativty, ((WatermarkFunction)request.Functions[0]).Gravity)); "And the point size should be 94".Observation(() => Assert.Equal(94, ((WatermarkFunction)request.Functions[0]).PointSize)); "And the font family should be Helvetica".Observation(() => Assert.Equal("Helvetica", ((WatermarkFunction)request.Functions[0]).FontFamily)); "And the opacity should be 0.45".Observation(() => Assert.Equal(0.45m, ((WatermarkFunction)request.Functions[0]).Opacity)); "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(Gravity.CenterGrativty, (Gravity)t.GetProperty("gravity").GetValue(p, null)); Assert.Equal(94, (int)t.GetProperty("point_size").GetValue(p, null)); Assert.Equal("Helvetica", t.GetProperty("font_family").GetValue(p, null).ToString()); Assert.Equal(0.45m, (decimal)t.GetProperty("opacity").GetValue(p, null)); }); }
public void CanProcessAnAnnotateFunction() { var request = default(BlitlineRequest); var response = default(BlitlineResponse); "Given I have a annotate function".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")) .Annotate(f => f.WithText("Hello") .WithColour("#FFF000") .WithPointSize(48) .WithFontFamilty("Arial") .WithGravity(Gravity.NorthEastGravity) .SaveAs(s => s.WithImageIdentifier("image_identifier") .ToS3(s3 => s3 .ToBucket(bucketName) .WithKey("annotate-full.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)); "And there should be no error reported".Observation(() => Assert.Null(response.Results.Error)); }
public void CanProcessMultipleImages() { "Given I have multiple images to process".Context(() => { const string bucketName = "gdoubleu-test-photos"; _requests = new List <BlitlineRequest> { 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("first_image") .ToS3(s3 => s3 .ToBucket(bucketName).WithKey("123"))))), 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("second_image") .ToS3(s3 => s3 .ToBucket(bucketName) .WithKey("multi-2.png"))))) }.ToArray(); }); "When I process the request".Do(() => _response = _requests.Send()); "Then there should be 2 results".Observation(() => Assert.Equal(2, _response.Results.Count())); }
public void CanBuildACropFunction() { BlitlineRequest request = default(BlitlineRequest); "When I build an crop function".Context(() => request = BuildA.Request(r => r .WithApplicationId("123") .WithSourceImageUri(new Uri("http://foo.bar.gif")) .Crop(f => f.WithDimensions(1, 2, 3, 4)))); "Then the name should be crop".Observation(() => Assert.Equal("crop", request.Functions[0].Name)); "And x should be 1".Observation(() => Assert.Equal(1, ((CropFunction)request.Functions[0]).X)); "And y should be 2".Observation(() => Assert.Equal(2, ((CropFunction)request.Functions[0]).Y)); "And width should be 3".Observation(() => Assert.Equal(3, ((CropFunction)request.Functions[0]).Width)); "And height should be 4".Observation(() => Assert.Equal(4, ((CropFunction)request.Functions[0]).Height)); "And the params should be constructed".Observation(() => { var p = request.Functions[0].Params; var t = p.GetType(); Assert.Equal(1, t.GetProperty("x").GetValue(p, null)); Assert.Equal(2, t.GetProperty("y").GetValue(p, null)); Assert.Equal(3, t.GetProperty("width").GetValue(p, null)); Assert.Equal(4, t.GetProperty("height").GetValue(p, null)); }); }
public void CanBuildARequestWithAnS3Destination() { 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) .ToS3(s3 => s3.ToBucket("Bucket") .WithKey("Key") .WithHeader("1", "foo") .WithHeaders(new Dictionary <string, string> { { "2", "bar" } })))))); "Then save contains an s3 destination".Observation(() => Assert.NotNull(request.Functions.First().Save.S3Destination)); "And the bucket name is Bucket".Observation(() => Assert.Equal("Bucket", request.Functions.First().Save.S3Destination.Bucket)); "And the key is Key".Observation(() => Assert.Equal("Key", request.Functions.First().Save.S3Destination.Key)); "And there are 2 headers".Observation(() => Assert.Equal(2, request.Functions.First().Save.S3Destination.Headers.Count)); "And the first header is foo".Observation(() => Assert.Equal("foo", request.Functions.First().Save.S3Destination.Headers.First().Value)); "And the second header is bar".Observation(() => Assert.Equal("bar", request.Functions.First().Save.S3Destination.Headers.Last().Value)); }
public void CanBuildAModulateFunction() { BlitlineRequest request = default(BlitlineRequest); "When I build a 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).WithColour("ccc").WithGravity(Gravity.NorthEastGravity)))); "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 ccc".Observation(() => Assert.Equal("ccc", ((PadResizeToFitFunction)request.Functions[0]).Colour)); "And the gravity should be NorthEastGravity".Observation(() => Assert.Equal(Gravity.NorthEastGravity, ((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("ccc", t.GetProperty("color").GetValue(p, null).ToString()); Assert.Equal("NorthEastGravity", t.GetProperty("gravity").GetValue(p, null).ToString()); }); }
public void CanBuildACompositeFunctionWithOnlyRequiredValues() { BlitlineRequest request = default(BlitlineRequest); "When I build a composite function".Context(() => request = BuildA.Request(r => r .WithApplicationId("123") .WithSourceImageUri(new Uri("http://foo.bar.gif")) .Composite(f => f.WithSource("source")))); "The the name should be composite".Observation(() => Assert.Equal("composite", request.Functions[0].Name)); "And the source should be source".Observation(() => Assert.Equal("source", ((CompositeFunction)request.Functions[0]).Source)); "And AsMask should be false".Observation(() => Assert.False(((CompositeFunction)request.Functions[0]).AsMask)); "And x should be 0".Observation(() => Assert.Equal(0, ((CompositeFunction)request.Functions[0]).X)); "And y should be 0".Observation(() => Assert.Equal(0, ((CompositeFunction)request.Functions[0]).Y)); "And the composite ops should be OverCompositeOp".Observation(() => Assert.Equal(CompositeOps.OverCompositeOp, ((CompositeFunction)request.Functions[0]).CompositeOp)); "And the params should be constructed".Observation(() => { var p = request.Functions[0].Params; var t = p.GetType(); Assert.Equal("source", t.GetProperty("src").GetValue(p, null).ToString()); Assert.Equal(false, (bool)t.GetProperty("as_mask").GetValue(p, null)); Assert.Equal(0, (int)t.GetProperty("x").GetValue(p, null)); Assert.Equal(0, (int)t.GetProperty("y").GetValue(p, null)); Assert.Equal("OverCompositeOp", t.GetProperty("composite_op").GetValue(p, null).ToString()); }); }
public void CanBuildAnAnnotateFunctionWithOnlyRequiredValues() { 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")))); "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 0".Observation(() => Assert.Equal(0, ((AnnotateFunction)request.Functions[0]).X)); "And the y should be 0".Observation(() => Assert.Equal(0, ((AnnotateFunction)request.Functions[0]).Y)); "And the colour should be #ffffff".Observation(() => Assert.Equal("#ffffff", ((AnnotateFunction)request.Functions[0]).Colour)); "And the font family should be Helvetica".Observation(() => Assert.Equal("Helvetica", ((AnnotateFunction)request.Functions[0]).FontFamily)); "And the point size should be 32".Observation(() => Assert.Equal(32, ((AnnotateFunction)request.Functions[0]).PointSize)); "And the stroke should be transparent".Observation(() => Assert.Equal("transparent", ((AnnotateFunction)request.Functions[0]).Stroke)); "And the gravity should be CenterGravity".Observation(() => Assert.Equal(Gravity.CenterGrativty, ((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(0, (int)t.GetProperty("x").GetValue(p, null)); Assert.Equal(0, (int)t.GetProperty("y").GetValue(p, null)); Assert.Equal("#ffffff", t.GetProperty("color").GetValue(p, null).ToString()); Assert.Equal("Helvetica", t.GetProperty("font_family").GetValue(p, null).ToString()); Assert.Equal(32, (int)t.GetProperty("point_size").GetValue(p, null)); Assert.Equal("transparent", t.GetProperty("stroke").GetValue(p, null).ToString()); Assert.Equal("CenterGrativty", t.GetProperty("gravity").GetValue(p, null).ToString()); }); }
public void CanBuildAVignetteFunction() { BlitlineRequest request = default(BlitlineRequest); "When I build a vignette function".Context(() => request = BuildA.Request(r => r .WithApplicationId("123") .WithSourceImageUri(new Uri("http://foo.bar.gif")) .Vignette(f => f.WithColour("ccc").WithPosition(2, 3) .WithThreshold(0.5m).WithSigma(4m).WithRadius(5m)))); "Then the name should be vignette".Observation(() => Assert.Equal("vignette", request.Functions[0].Name)); "And the colour should be ccc".Observation(() => Assert.Equal("ccc", ((VignetteFunction)request.Functions[0]).Colour)); "And x should be 2".Observation(() => Assert.Equal(2, ((VignetteFunction)request.Functions[0]).X)); "And y should be 3".Observation(() => Assert.Equal(3, ((VignetteFunction)request.Functions[0]).Y)); "And the threshold should be 0.5".Observation(() => Assert.Equal(0.5m, ((VignetteFunction)request.Functions[0]).Threshold)); "And the sigma should be 4".Observation(() => Assert.Equal(4m, ((VignetteFunction)request.Functions[0]).Sigma)); "And the radius should be 5".Observation(() => Assert.Equal(5m, ((VignetteFunction)request.Functions[0]).Radius)); "And the params should be constructed".Observation(() => { var p = request.Functions[0].Params; var t = p.GetType(); Assert.Equal("ccc", t.GetProperty("color").GetValue(p, null).ToString()); Assert.Equal(2, (int)t.GetProperty("x").GetValue(p, null)); Assert.Equal(3, (int)t.GetProperty("y").GetValue(p, null)); Assert.Equal(0.5m, (decimal)t.GetProperty("threshold").GetValue(p, null)); Assert.Equal(4m, (decimal)t.GetProperty("sigma").GetValue(p, null)); Assert.Equal(5m, (decimal)t.GetProperty("radius").GetValue(p, null)); }); }
public void CanBuildARequestWithAnFtpDestination() { 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) .ToFtp(f => f.WithServer("ftp://ftp.foo.com") .WithUser("bob") .WithPassword("smith") .WithFileName("bar.gif") .WithDirectory("/images")) ) ) )); "Then the save contains an ftp destination".Observation(() => Assert.NotNull(request.Functions.First().Save.FtpDestination)); "And the ftp server is ftp://ftp.foo.com".Observation(() => Assert.Equal("ftp://ftp.foo.com", request.Functions.First().Save.FtpDestination.Server)); "And the ftp user is bob".Observation(() => Assert.Equal("bob", request.Functions.First().Save.FtpDestination.User)); "And the ftp password is smith".Observation(() => Assert.Equal("smith", request.Functions.First().Save.FtpDestination.Password)); "And the ftp filename is bar.gif".Observation(() => Assert.Equal("bar.gif", request.Functions.First().Save.FtpDestination.FileName)); "And the ftp directory is /images".Observation(() => Assert.Equal("/images", request.Functions.First().Save.FtpDestination.Directory)); }
public void CanNotBuildAnUnsharpMaskFunctionWhenAmountOutOfBounds() { Assert.Throws <ArgumentException>(() => BuildA.Request(r => r.WithApplicationId("123") .WithSourceImageUri(new Uri("http://foo.bar.gif")) .UnsharpMask( f => f.WithAmount(1.1m).WithThreshold(0.1m)))); }
public void CanNotBuildAScaleFunctionWithScaleFactorWidthAndHightSet() { Assert.Throws <ArgumentException>(() => BuildA.Request(r => r .WithApplicationId("123") .WithSourceImageUri(new Uri("http://foo.bar.gif")) .Scale( f => f.WithHeight(10).WithWidth(5).WithScaleFactor(0.4m)))); }
public void CanNotBuildAVignetteFunctionWhereThresoldOutOfBounds() { Assert.Throws <ArgumentException>(() => BuildA.Request(r => r .WithApplicationId("123") .WithSourceImageUri(new Uri("http://foo.bar.gif")) .Vignette(f => f.WithThreshold(2m)))); }
public void CanBuildAScriptFunctionWithBashString() { BlitlineRequest request = default(BlitlineRequest); "When I build an script function".Context(() => request = BuildA.Request(r => r .WithApplicationId("123") .WithSourceImageUri(new Uri("http://foo.bar.gif")) .Script(f => f.WithBashString("something")))); "Then the name should be script".Observation(() => Assert.Equal("script", request.Functions[0].Name)); "And the bash string should be something".Observation(() => Assert.Equal("something", ((ScriptFunction)request.Functions[0]).BashString)); }
public void CanBuildAScriptFunctionWithFilesAndExecutables() { BlitlineRequest request = default(BlitlineRequest); "When I build an script function".Context(() => request = BuildA.Request(r => r .WithApplicationId("123") .WithSourceImageUri(new Uri("http://foo.bar.gif")) .Script(f => f.WithFiles("files").WithExecutable("executable")))); "Then the name should be script".Observation(() => Assert.Equal("script", request.Functions[0].Name)); "And the files should be files".Observation(() => Assert.Equal("files", ((ScriptFunction)request.Functions[0]).Files)); "And the executables should be executable".Observation(() => Assert.Equal("executable", ((ScriptFunction)request.Functions[0]).Executable)); }
public void CanBuildARequestWithSubFunctions() { BlitlineRequest request = default(BlitlineRequest); "When I build a request with sub functions".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) .Deskew(d => d.WithThreshold(0.2m))))); "Then the primary function has 1 sub-function".Observation( () => Assert.Equal(1, request.Functions.First().Functions.Count)); }
public static void Main(string [] args) { const string applicationKey = "a5KqkemeX2RttyYdkOrdug"; const string bucketName = "gdoubleu-test-photos"; const string sourceImage = "https://s3-eu-west-1.amazonaws.com/gdoubleu-test-photos/moi.jpg"; const string imageIdentifier = "foo.png"; var request = BuildA.Request(r => r .WithApplicationId(applicationKey) .WithSourceImageUri(new Uri(sourceImage)) .Crop(f => f.WithGravity(Blitline.Net.ParamOptions.Gravity.NorthGravity).SaveAs(s => s.WithImageIdentifier(imageIdentifier).ToS3(s3 => s3.ToBucket(bucketName).WithKey("annotate-default.png"))))); var response = request.Send(); Console.Read(); }
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")))))); }
public void CanBuildADeleteProfileFunction() { BlitlineRequest request = default(BlitlineRequest); "When I build a delete profile function".Context(() => request = BuildA.Request(r => r .WithApplicationId("123") .WithSourceImageUri(new Uri("http://foo.bar.gif")) .DeleteProfile(f => f.WithProfileName("profile")))); "Then the name should be delete_profile".Observation(() => Assert.Equal("delete_profile", request.Functions[0].Name)); "And profile name should be set to profile".Observation(() => Assert.Equal("profile", ((DeleteProfileFunction)request.Functions[0]).ProfileName)); "And the params should be constructed".Observation(() => { var p = request.Functions[0].Params; var t = p.GetType(); Assert.Equal("profile", t.GetProperty("name").GetValue(p, null)); }); }
public void CanBuildAContrastFunction() { BlitlineRequest request = default(BlitlineRequest); "When I build an contrast function".Context(() => request = BuildA.Request(r => r .WithApplicationId("123") .WithSourceImageUri(new Uri("http://foo.bar.gif")) .Contrast(f => f.Sharpen(true)))); "Then the name should be contrast".Observation(() => Assert.Equal("contrast", request.Functions[0].Name)); "And the sharpen should be true".Observation(() => Assert.Equal(true, ((ContrastFunction)request.Functions[0]).Sharpen)); "And the params should be constructed".Observation(() => { var p = request.Functions[0].Params; var t = p.GetType(); Assert.Equal(true, (bool)t.GetProperty("sharpen").GetValue(p, null)); }); }
public void CanBuildAGammaChannelFunction() { BlitlineRequest request = default(BlitlineRequest); "When I build a gamma channel function".Context(() => request = BuildA.Request(r => r .WithApplicationId("123") .WithSourceImageUri(new Uri("http://foo.bar.gif")) .GammaChannel(f => f.WithGamma(3.5m)))); "Then the name should be gamma_channel".Observation(() => Assert.Equal("gamma_channel", request.Functions[0].Name)); "And the gamma should be 3.5".Observation(() => Assert.Equal(3.5m, ((GammaChannelFunction)request.Functions[0]).Gamma)); "And the params should be constructed".Observation(() => { var p = request.Functions[0].Params; var t = p.GetType(); Assert.Equal(3.5m, (decimal)t.GetProperty("gamma").GetValue(p, null)); }); }
public void CanBuildADensityFunction() { BlitlineRequest request = default(BlitlineRequest); "When I build a density function".Context(() => request = BuildA.Request(r => r .WithApplicationId("123") .WithSourceImageUri(new Uri("http://foo.bar.gif")) .Density(f => f.WithDpi(300)))); "Then the name should be density".Observation(() => Assert.Equal("density", request.Functions[0].Name)); "And dpi should be 300".Observation(() => Assert.Equal(300, ((DensityFunction)request.Functions[0]).Dpi)); "And the params should be constructed".Observation(() => { var p = request.Functions[0].Params; var t = p.GetType(); Assert.Equal(300, t.GetProperty("dpi").GetValue(p, null)); }); }
public void CanBuildAnAppendFunction() { BlitlineRequest request = default(BlitlineRequest); "When I build a rotate function".Context(() => request = BuildA.Request(r => r .WithApplicationId("123") .WithSourceImageUri(new Uri("http://foo.bar.gif")) .Rotate(f => f.WithAmount(10)))); "Then the name should be rotate".Observation(() => Assert.Equal("rotate", request.Functions[0].Name)); "And the amount should be 10".Observation(() => Assert.Equal(10, ((RotateFunction)request.Functions[0]).Amount)); "And the params should be constructed".Observation(() => { var p = request.Functions[0].Params; var t = p.GetType(); Assert.Equal(10, (int)t.GetProperty("amount").GetValue(p, null)); }); }
public void CanBuildASepeiaToneFunction() { BlitlineRequest request = default(BlitlineRequest); "When I build an sepia tone function".Context(() => request = BuildA.Request(r => r .WithApplicationId("123") .WithSourceImageUri(new Uri("http://foo.bar.gif")) .SepiaTone(f => f.WithThreshold(1)))); "Then the name should be sepia_tone".Observation(() => Assert.Equal("sepia_tone", request.Functions[0].Name)); "And the threshold should be 1".Observation(() => Assert.Equal(1, ((SepiaToneFunction)request.Functions[0]).Threshold)); "And the params should be constructed".Observation(() => { var p = request.Functions[0].Params; var t = p.GetType(); Assert.Equal(1, (int)t.GetProperty("threshold").GetValue(p, null)); }); }
public void CanChangeImageFileExtension() { "Given I have a request which specifies a different file extension".Context(() => { _request = BuildA.Request(r => r .WithApplicationId("a5KqkemeX2RttyYdkOrdug") .WithSourceImageUri( new Uri("https://s3-eu-west-1.amazonaws.com/gdoubleu-test-photos/moi.jpg")) .Crop(f => f.WithDimensions(51, 126, 457 - 126, 382 - 51) .SaveAs( s => s.WithImageIdentifier("file_extension") .WithExtension(Extension.PNG)))); }); "When I process the request".Do(() => _response = _request.Send()); "Then the processed image should contain the new extension".Observation(() => Assert.Contains(".png", _response.Results.Images.First().S3Url)); }
public void CanBuildADeskewFunction() { BlitlineRequest request = default(BlitlineRequest); "When I build a deskew function".Context(() => request = BuildA.Request(r => r .WithApplicationId("123") .WithSourceImageUri(new Uri("http://foo.bar.gif")) .Deskew(f => f.WithThreshold(1m)))); "Then the name should be deskew".Observation(() => Assert.Equal("deskew", request.Functions[0].Name)); "And threshold should be 1".Observation(() => Assert.Equal(1, ((DeskewFunction)request.Functions[0]).Threshold)); "And the params should be constructed".Observation(() => { var p = request.Functions[0].Params; var t = p.GetType(); Assert.Equal(1, (decimal)t.GetProperty("threshold").GetValue(p, null)); }); }
public void CannotBuildARequestWithoutASaveImageIdentifier() { Assert.Throws <ArgumentNullException>(() => 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 .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")))))); }
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)); }); }