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()); }); }
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 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 ShouldGenerateAnError() { "Give I have an incomplete request".Context(() => { _blitline = new BlitlineApi(); _request = new BlitlineRequest("blah", "https://s3-eu-west-1.amazonaws.com/gdoubleu-blitline/moi.jpg"); var cropFunction = new CropFunction { X = 51, Y = 126, Width = 457 - 126, Height = 382 - 51, Save = new Save { ImageIdentifier = "image_identifier" } }; _request.AddFunction(cropFunction); }); "When I process the request".Do(() => _response = _blitline.ProcessImages(_request)); "Then the response should fail".Observation(() => Assert.True(_response.Failed)); "And the response should contain an error".Observation(() => Assert.NotEmpty(_response.Results.Error)); }
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 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 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 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 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])); }
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 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)); }); }
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 async Task <BlitlineResponse> ProcessImagesAsync(BlitlineRequest blitlineRequest) { var r = await ProcessImagesAsync(new[] { blitlineRequest }); return(new BlitlineResponse { Results = r.Results.First() }); }
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 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 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 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 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)); }); }
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 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 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 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 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)); }); }
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 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)); }
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)); }); }
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()); }); }
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); }); }