Browse Source

Tweek extension names

pull/1574/head
Scott Williams 6 years ago
parent
commit
e65febf329
  1. 22
      src/ImageSharp/GraphicOptionsDefaultsExtensions.cs
  2. 8
      src/ImageSharp/Processing/Extensions/Drawing/DrawImageExtensions.cs
  3. 4
      src/ImageSharp/Processing/Extensions/Filters/LomographExtensions.cs
  4. 4
      src/ImageSharp/Processing/Extensions/Filters/PolaroidExtensions.cs
  5. 4
      src/ImageSharp/Processing/Extensions/Overlays/BackgroundColorExtensions.cs
  6. 10
      src/ImageSharp/Processing/Extensions/Overlays/GlowExtensions.cs
  7. 10
      src/ImageSharp/Processing/Extensions/Overlays/VignetteExtensions.cs
  8. 42
      tests/ImageSharp.Tests/GraphicOptionsDefaultsExtensionsTests.cs
  9. 3
      tests/ImageSharp.Tests/Processing/BaseImageOperationsExtensionTest.cs
  10. 4
      tests/ImageSharp.Tests/Processing/Filters/ContrastTest.cs

22
src/ImageSharp/GraphicOptionsDefaultsExtensions.cs

@ -16,11 +16,13 @@ namespace SixLabors.ImageSharp
/// </summary> /// </summary>
/// <param name="context">The image processing context to store default against.</param> /// <param name="context">The image processing context to store default against.</param>
/// <param name="optionsBuilder">The action to update instance of the default options used.</param> /// <param name="optionsBuilder">The action to update instance of the default options used.</param>
public static void SetDefaultOptions(this IImageProcessingContext context, Action<GraphicsOptions> optionsBuilder) /// <returns>The passed in <paramref name="context"/> to allow chaining.</returns>
public static IImageProcessingContext SetGraphicsOptions(this IImageProcessingContext context, Action<GraphicsOptions> optionsBuilder)
{ {
var cloned = context.GetDefaultGraphicsOptions().DeepClone(); var cloned = context.GetGraphicsOptions().DeepClone();
optionsBuilder(cloned); optionsBuilder(cloned);
context.Properties[typeof(GraphicsOptions)] = cloned; context.Properties[typeof(GraphicsOptions)] = cloned;
return context;
} }
/// <summary> /// <summary>
@ -28,9 +30,9 @@ namespace SixLabors.ImageSharp
/// </summary> /// </summary>
/// <param name="context">The image processing context to store default against.</param> /// <param name="context">The image processing context to store default against.</param>
/// <param name="optionsBuilder">The default options to use.</param> /// <param name="optionsBuilder">The default options to use.</param>
public static void SetDefaultGraphicsOptions(this Configuration context, Action<GraphicsOptions> optionsBuilder) public static void SetGraphicsOptions(this Configuration context, Action<GraphicsOptions> optionsBuilder)
{ {
var cloned = context.GetDefaultGraphicsOptions().DeepClone(); var cloned = context.GetGraphicsOptions().DeepClone();
optionsBuilder(cloned); optionsBuilder(cloned);
context.Properties[typeof(GraphicsOptions)] = cloned; context.Properties[typeof(GraphicsOptions)] = cloned;
} }
@ -40,9 +42,11 @@ namespace SixLabors.ImageSharp
/// </summary> /// </summary>
/// <param name="context">The image processing context to store default against.</param> /// <param name="context">The image processing context to store default against.</param>
/// <param name="options">The default options to use.</param> /// <param name="options">The default options to use.</param>
public static void SetDefaultOptions(this IImageProcessingContext context, GraphicsOptions options) /// <returns>The passed in <paramref name="context"/> to allow chaining.</returns>
public static IImageProcessingContext SetGraphicsOptions(this IImageProcessingContext context, GraphicsOptions options)
{ {
context.Properties[typeof(GraphicsOptions)] = options; context.Properties[typeof(GraphicsOptions)] = options;
return context;
} }
/// <summary> /// <summary>
@ -50,7 +54,7 @@ namespace SixLabors.ImageSharp
/// </summary> /// </summary>
/// <param name="context">The image processing context to store default against.</param> /// <param name="context">The image processing context to store default against.</param>
/// <param name="options">The default options to use.</param> /// <param name="options">The default options to use.</param>
public static void SetDefaultGraphicsOptions(this Configuration context, GraphicsOptions options) public static void SetGraphicsOptions(this Configuration context, GraphicsOptions options)
{ {
context.Properties[typeof(GraphicsOptions)] = options; context.Properties[typeof(GraphicsOptions)] = options;
} }
@ -60,14 +64,14 @@ namespace SixLabors.ImageSharp
/// </summary> /// </summary>
/// <param name="context">The image processing context to retrieve defaults from.</param> /// <param name="context">The image processing context to retrieve defaults from.</param>
/// <returns>The globaly configued default options.</returns> /// <returns>The globaly configued default options.</returns>
public static GraphicsOptions GetDefaultGraphicsOptions(this IImageProcessingContext context) public static GraphicsOptions GetGraphicsOptions(this IImageProcessingContext context)
{ {
if (context.Properties.TryGetValue(typeof(GraphicsOptions), out var options) && options is GraphicsOptions go) if (context.Properties.TryGetValue(typeof(GraphicsOptions), out var options) && options is GraphicsOptions go)
{ {
return go; return go;
} }
var configOptions = context.Configuration.GetDefaultGraphicsOptions(); var configOptions = context.Configuration.GetGraphicsOptions();
// do not cache the fall back to config into the the processing context // do not cache the fall back to config into the the processing context
// in case someone want to change the value on the config and expects it re trflow thru // in case someone want to change the value on the config and expects it re trflow thru
@ -79,7 +83,7 @@ namespace SixLabors.ImageSharp
/// </summary> /// </summary>
/// <param name="context">The image processing context to retrieve defaults from.</param> /// <param name="context">The image processing context to retrieve defaults from.</param>
/// <returns>The globaly configued default options.</returns> /// <returns>The globaly configued default options.</returns>
public static GraphicsOptions GetDefaultGraphicsOptions(this Configuration context) public static GraphicsOptions GetGraphicsOptions(this Configuration context)
{ {
if (context.Properties.TryGetValue(typeof(GraphicsOptions), out var options) && options is GraphicsOptions go) if (context.Properties.TryGetValue(typeof(GraphicsOptions), out var options) && options is GraphicsOptions go)
{ {

8
src/ImageSharp/Processing/Extensions/Drawing/DrawImageExtensions.cs

@ -23,7 +23,7 @@ namespace SixLabors.ImageSharp.Processing
Image image, Image image,
float opacity) float opacity)
{ {
var options = source.GetDefaultGraphicsOptions(); var options = source.GetGraphicsOptions();
return source.ApplyProcessor( return source.ApplyProcessor(
new DrawImageProcessor( new DrawImageProcessor(
image, image,
@ -51,7 +51,7 @@ namespace SixLabors.ImageSharp.Processing
image, image,
Point.Empty, Point.Empty,
colorBlending, colorBlending,
source.GetDefaultGraphicsOptions().AlphaCompositionMode, source.GetGraphicsOptions().AlphaCompositionMode,
opacity)); opacity));
/// <summary> /// <summary>
@ -104,7 +104,7 @@ namespace SixLabors.ImageSharp.Processing
Point location, Point location,
float opacity) float opacity)
{ {
var options = source.GetDefaultGraphicsOptions(); var options = source.GetGraphicsOptions();
return source.ApplyProcessor( return source.ApplyProcessor(
new DrawImageProcessor( new DrawImageProcessor(
image, image,
@ -134,7 +134,7 @@ namespace SixLabors.ImageSharp.Processing
image, image,
location, location,
colorBlending, colorBlending,
source.GetDefaultGraphicsOptions().AlphaCompositionMode, source.GetGraphicsOptions().AlphaCompositionMode,
opacity)); opacity));
/// <summary> /// <summary>

4
src/ImageSharp/Processing/Extensions/Filters/LomographExtensions.cs

@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.Processing
/// <param name="source">The image this method extends.</param> /// <param name="source">The image this method extends.</param>
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns> /// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
public static IImageProcessingContext Lomograph(this IImageProcessingContext source) public static IImageProcessingContext Lomograph(this IImageProcessingContext source)
=> source.ApplyProcessor(new LomographProcessor(source.GetDefaultGraphicsOptions())); => source.ApplyProcessor(new LomographProcessor(source.GetGraphicsOptions()));
/// <summary> /// <summary>
/// Alters the colors of the image recreating an old Lomograph camera effect. /// Alters the colors of the image recreating an old Lomograph camera effect.
@ -28,6 +28,6 @@ namespace SixLabors.ImageSharp.Processing
/// </param> /// </param>
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns> /// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
public static IImageProcessingContext Lomograph(this IImageProcessingContext source, Rectangle rectangle) public static IImageProcessingContext Lomograph(this IImageProcessingContext source, Rectangle rectangle)
=> source.ApplyProcessor(new LomographProcessor(source.GetDefaultGraphicsOptions()), rectangle); => source.ApplyProcessor(new LomographProcessor(source.GetGraphicsOptions()), rectangle);
} }
} }

4
src/ImageSharp/Processing/Extensions/Filters/PolaroidExtensions.cs

@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.Processing
/// <param name="source">The image this method extends.</param> /// <param name="source">The image this method extends.</param>
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns> /// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
public static IImageProcessingContext Polaroid(this IImageProcessingContext source) public static IImageProcessingContext Polaroid(this IImageProcessingContext source)
=> source.ApplyProcessor(new PolaroidProcessor(source.GetDefaultGraphicsOptions())); => source.ApplyProcessor(new PolaroidProcessor(source.GetGraphicsOptions()));
/// <summary> /// <summary>
/// Alters the colors of the image recreating an old Polaroid camera effect. /// Alters the colors of the image recreating an old Polaroid camera effect.
@ -28,6 +28,6 @@ namespace SixLabors.ImageSharp.Processing
/// </param> /// </param>
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns> /// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
public static IImageProcessingContext Polaroid(this IImageProcessingContext source, Rectangle rectangle) public static IImageProcessingContext Polaroid(this IImageProcessingContext source, Rectangle rectangle)
=> source.ApplyProcessor(new PolaroidProcessor(source.GetDefaultGraphicsOptions()), rectangle); => source.ApplyProcessor(new PolaroidProcessor(source.GetGraphicsOptions()), rectangle);
} }
} }

4
src/ImageSharp/Processing/Extensions/Overlays/BackgroundColorExtensions.cs

@ -18,7 +18,7 @@ namespace SixLabors.ImageSharp.Processing
/// <param name="color">The color to set as the background.</param> /// <param name="color">The color to set as the background.</param>
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns> /// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
public static IImageProcessingContext BackgroundColor(this IImageProcessingContext source, Color color) => public static IImageProcessingContext BackgroundColor(this IImageProcessingContext source, Color color) =>
BackgroundColor(source, source.GetDefaultGraphicsOptions(), color); BackgroundColor(source, source.GetGraphicsOptions(), color);
/// <summary> /// <summary>
/// Replaces the background color of image with the given one. /// Replaces the background color of image with the given one.
@ -33,7 +33,7 @@ namespace SixLabors.ImageSharp.Processing
this IImageProcessingContext source, this IImageProcessingContext source,
Color color, Color color,
Rectangle rectangle) => Rectangle rectangle) =>
BackgroundColor(source, source.GetDefaultGraphicsOptions(), color, rectangle); BackgroundColor(source, source.GetGraphicsOptions(), color, rectangle);
/// <summary> /// <summary>
/// Replaces the background color of image with the given one. /// Replaces the background color of image with the given one.

10
src/ImageSharp/Processing/Extensions/Overlays/GlowExtensions.cs

@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.Processing
/// <param name="source">The image this method extends.</param> /// <param name="source">The image this method extends.</param>
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns> /// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
public static IImageProcessingContext Glow(this IImageProcessingContext source) => public static IImageProcessingContext Glow(this IImageProcessingContext source) =>
Glow(source, source.GetDefaultGraphicsOptions()); Glow(source, source.GetGraphicsOptions());
/// <summary> /// <summary>
/// Applies a radial glow effect to an image. /// Applies a radial glow effect to an image.
@ -27,7 +27,7 @@ namespace SixLabors.ImageSharp.Processing
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns> /// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
public static IImageProcessingContext Glow(this IImageProcessingContext source, Color color) public static IImageProcessingContext Glow(this IImageProcessingContext source, Color color)
{ {
return Glow(source, source.GetDefaultGraphicsOptions(), color); return Glow(source, source.GetGraphicsOptions(), color);
} }
/// <summary> /// <summary>
@ -37,7 +37,7 @@ namespace SixLabors.ImageSharp.Processing
/// <param name="radius">The the radius.</param> /// <param name="radius">The the radius.</param>
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns> /// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
public static IImageProcessingContext Glow(this IImageProcessingContext source, float radius) => public static IImageProcessingContext Glow(this IImageProcessingContext source, float radius) =>
Glow(source, source.GetDefaultGraphicsOptions(), radius); Glow(source, source.GetGraphicsOptions(), radius);
/// <summary> /// <summary>
/// Applies a radial glow effect to an image. /// Applies a radial glow effect to an image.
@ -48,7 +48,7 @@ namespace SixLabors.ImageSharp.Processing
/// </param> /// </param>
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns> /// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
public static IImageProcessingContext Glow(this IImageProcessingContext source, Rectangle rectangle) => public static IImageProcessingContext Glow(this IImageProcessingContext source, Rectangle rectangle) =>
source.Glow(source.GetDefaultGraphicsOptions(), rectangle); source.Glow(source.GetGraphicsOptions(), rectangle);
/// <summary> /// <summary>
/// Applies a radial glow effect to an image. /// Applies a radial glow effect to an image.
@ -65,7 +65,7 @@ namespace SixLabors.ImageSharp.Processing
Color color, Color color,
float radius, float radius,
Rectangle rectangle) => Rectangle rectangle) =>
source.Glow(source.GetDefaultGraphicsOptions(), color, ValueSize.Absolute(radius), rectangle); source.Glow(source.GetGraphicsOptions(), color, ValueSize.Absolute(radius), rectangle);
/// <summary> /// <summary>
/// Applies a radial glow effect to an image. /// Applies a radial glow effect to an image.

10
src/ImageSharp/Processing/Extensions/Overlays/VignetteExtensions.cs

@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.Processing
/// <param name="source">The image this method extends.</param> /// <param name="source">The image this method extends.</param>
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns> /// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
public static IImageProcessingContext Vignette(this IImageProcessingContext source) => public static IImageProcessingContext Vignette(this IImageProcessingContext source) =>
Vignette(source, source.GetDefaultGraphicsOptions()); Vignette(source, source.GetGraphicsOptions());
/// <summary> /// <summary>
/// Applies a radial vignette effect to an image. /// Applies a radial vignette effect to an image.
@ -26,7 +26,7 @@ namespace SixLabors.ImageSharp.Processing
/// <param name="color">The color to set as the vignette.</param> /// <param name="color">The color to set as the vignette.</param>
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns> /// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
public static IImageProcessingContext Vignette(this IImageProcessingContext source, Color color) => public static IImageProcessingContext Vignette(this IImageProcessingContext source, Color color) =>
Vignette(source, source.GetDefaultGraphicsOptions(), color); Vignette(source, source.GetGraphicsOptions(), color);
/// <summary> /// <summary>
/// Applies a radial vignette effect to an image. /// Applies a radial vignette effect to an image.
@ -39,7 +39,7 @@ namespace SixLabors.ImageSharp.Processing
this IImageProcessingContext source, this IImageProcessingContext source,
float radiusX, float radiusX,
float radiusY) => float radiusY) =>
Vignette(source, source.GetDefaultGraphicsOptions(), radiusX, radiusY); Vignette(source, source.GetGraphicsOptions(), radiusX, radiusY);
/// <summary> /// <summary>
/// Applies a radial vignette effect to an image. /// Applies a radial vignette effect to an image.
@ -50,7 +50,7 @@ namespace SixLabors.ImageSharp.Processing
/// </param> /// </param>
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns> /// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
public static IImageProcessingContext Vignette(this IImageProcessingContext source, Rectangle rectangle) => public static IImageProcessingContext Vignette(this IImageProcessingContext source, Rectangle rectangle) =>
Vignette(source, source.GetDefaultGraphicsOptions(), rectangle); Vignette(source, source.GetGraphicsOptions(), rectangle);
/// <summary> /// <summary>
/// Applies a radial vignette effect to an image. /// Applies a radial vignette effect to an image.
@ -69,7 +69,7 @@ namespace SixLabors.ImageSharp.Processing
float radiusX, float radiusX,
float radiusY, float radiusY,
Rectangle rectangle) => Rectangle rectangle) =>
source.Vignette(source.GetDefaultGraphicsOptions(), color, radiusX, radiusY, rectangle); source.Vignette(source.GetGraphicsOptions(), color, radiusX, radiusY, rectangle);
/// <summary> /// <summary>
/// Applies a radial vignette effect to an image. /// Applies a radial vignette effect to an image.

42
tests/ImageSharp.Tests/GraphicOptionsDefaultsExtensionsTests.cs

@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.Tests
var config = new Configuration(); var config = new Configuration();
var context = new FakeImageOperationsProvider.FakeImageOperations<Rgba32>(config, null, true); var context = new FakeImageOperationsProvider.FakeImageOperations<Rgba32>(config, null, true);
context.SetDefaultOptions(option); context.SetGraphicsOptions(option);
// sets the prop on the processing context not on the configuration // sets the prop on the processing context not on the configuration
Assert.Equal(option, context.Properties[typeof(GraphicsOptions)]); Assert.Equal(option, context.Properties[typeof(GraphicsOptions)]);
@ -33,15 +33,15 @@ namespace SixLabors.ImageSharp.Tests
}; };
var config = new Configuration(); var config = new Configuration();
var context = new FakeImageOperationsProvider.FakeImageOperations<Rgba32>(config, null, true); var context = new FakeImageOperationsProvider.FakeImageOperations<Rgba32>(config, null, true);
context.SetDefaultOptions(option); context.SetGraphicsOptions(option);
context.SetDefaultOptions(o => context.SetGraphicsOptions(o =>
{ {
Assert.Equal(0.9f, o.BlendPercentage); // has origional values Assert.Equal(0.9f, o.BlendPercentage); // has origional values
o.BlendPercentage = 0.4f; o.BlendPercentage = 0.4f;
}); });
var returnedOption = context.GetDefaultGraphicsOptions(); var returnedOption = context.GetGraphicsOptions();
Assert.Equal(0.4f, returnedOption.BlendPercentage); Assert.Equal(0.4f, returnedOption.BlendPercentage);
Assert.Equal(0.9f, option.BlendPercentage); // hasn't been mutated Assert.Equal(0.9f, option.BlendPercentage); // hasn't been mutated
} }
@ -52,7 +52,7 @@ namespace SixLabors.ImageSharp.Tests
var option = new GraphicsOptions(); var option = new GraphicsOptions();
var config = new Configuration(); var config = new Configuration();
config.SetDefaultGraphicsOptions(option); config.SetGraphicsOptions(option);
Assert.Equal(option, config.Properties[typeof(GraphicsOptions)]); Assert.Equal(option, config.Properties[typeof(GraphicsOptions)]);
} }
@ -65,15 +65,15 @@ namespace SixLabors.ImageSharp.Tests
BlendPercentage = 0.9f BlendPercentage = 0.9f
}; };
var config = new Configuration(); var config = new Configuration();
config.SetDefaultGraphicsOptions(option); config.SetGraphicsOptions(option);
config.SetDefaultGraphicsOptions(o => config.SetGraphicsOptions(o =>
{ {
Assert.Equal(0.9f, o.BlendPercentage); // has origional values Assert.Equal(0.9f, o.BlendPercentage); // has origional values
o.BlendPercentage = 0.4f; o.BlendPercentage = 0.4f;
}); });
var returnedOption = config.GetDefaultGraphicsOptions(); var returnedOption = config.GetGraphicsOptions();
Assert.Equal(0.4f, returnedOption.BlendPercentage); Assert.Equal(0.4f, returnedOption.BlendPercentage);
Assert.Equal(0.9f, option.BlendPercentage); // hasn't been mutated Assert.Equal(0.9f, option.BlendPercentage); // hasn't been mutated
} }
@ -83,11 +83,11 @@ namespace SixLabors.ImageSharp.Tests
{ {
var config = new Configuration(); var config = new Configuration();
var options = config.GetDefaultGraphicsOptions(); var options = config.GetGraphicsOptions();
Assert.NotNull(options); Assert.NotNull(options);
config.SetDefaultGraphicsOptions((GraphicsOptions)null); config.SetGraphicsOptions((GraphicsOptions)null);
var options2 = config.GetDefaultGraphicsOptions(); var options2 = config.GetGraphicsOptions();
Assert.NotNull(options2); Assert.NotNull(options2);
// we set it to null should now be a new instance // we set it to null should now be a new instance
@ -100,7 +100,7 @@ namespace SixLabors.ImageSharp.Tests
var config = new Configuration(); var config = new Configuration();
config.Properties[typeof(GraphicsOptions)] = "wronge type"; config.Properties[typeof(GraphicsOptions)] = "wronge type";
var options = config.GetDefaultGraphicsOptions(); var options = config.GetGraphicsOptions();
Assert.NotNull(options); Assert.NotNull(options);
Assert.IsType<GraphicsOptions>(options); Assert.IsType<GraphicsOptions>(options);
} }
@ -111,7 +111,7 @@ namespace SixLabors.ImageSharp.Tests
var config = new Configuration(); var config = new Configuration();
Assert.DoesNotContain(typeof(GraphicsOptions), config.Properties.Keys); Assert.DoesNotContain(typeof(GraphicsOptions), config.Properties.Keys);
var options = config.GetDefaultGraphicsOptions(); var options = config.GetGraphicsOptions();
Assert.NotNull(options); Assert.NotNull(options);
} }
@ -120,8 +120,8 @@ namespace SixLabors.ImageSharp.Tests
{ {
var config = new Configuration(); var config = new Configuration();
var options = config.GetDefaultGraphicsOptions(); var options = config.GetGraphicsOptions();
var options2 = config.GetDefaultGraphicsOptions(); var options2 = config.GetGraphicsOptions();
Assert.Equal(options, options2); Assert.Equal(options, options2);
} }
@ -131,7 +131,7 @@ namespace SixLabors.ImageSharp.Tests
var config = new Configuration(); var config = new Configuration();
var context = new FakeImageOperationsProvider.FakeImageOperations<Rgba32>(config, null, true); var context = new FakeImageOperationsProvider.FakeImageOperations<Rgba32>(config, null, true);
var ctxOptions = context.GetDefaultGraphicsOptions(); var ctxOptions = context.GetGraphicsOptions();
Assert.NotNull(ctxOptions); Assert.NotNull(ctxOptions);
} }
@ -141,8 +141,8 @@ namespace SixLabors.ImageSharp.Tests
var config = new Configuration(); var config = new Configuration();
var context = new FakeImageOperationsProvider.FakeImageOperations<Rgba32>(config, null, true); var context = new FakeImageOperationsProvider.FakeImageOperations<Rgba32>(config, null, true);
context.SetDefaultOptions((GraphicsOptions)null); context.SetGraphicsOptions((GraphicsOptions)null);
var ctxOptions = context.GetDefaultGraphicsOptions(); var ctxOptions = context.GetGraphicsOptions();
Assert.NotNull(ctxOptions); Assert.NotNull(ctxOptions);
} }
@ -151,10 +151,10 @@ namespace SixLabors.ImageSharp.Tests
{ {
var option = new GraphicsOptions(); var option = new GraphicsOptions();
var config = new Configuration(); var config = new Configuration();
config.SetDefaultGraphicsOptions(option); config.SetGraphicsOptions(option);
var context = new FakeImageOperationsProvider.FakeImageOperations<Rgba32>(config, null, true); var context = new FakeImageOperationsProvider.FakeImageOperations<Rgba32>(config, null, true);
var ctxOptions = context.GetDefaultGraphicsOptions(); var ctxOptions = context.GetGraphicsOptions();
Assert.Equal(option, ctxOptions); Assert.Equal(option, ctxOptions);
} }
@ -164,7 +164,7 @@ namespace SixLabors.ImageSharp.Tests
var config = new Configuration(); var config = new Configuration();
var context = new FakeImageOperationsProvider.FakeImageOperations<Rgba32>(config, null, true); var context = new FakeImageOperationsProvider.FakeImageOperations<Rgba32>(config, null, true);
context.Properties[typeof(GraphicsOptions)] = "wronge type"; context.Properties[typeof(GraphicsOptions)] = "wronge type";
var options = context.GetDefaultGraphicsOptions(); var options = context.GetGraphicsOptions();
Assert.NotNull(options); Assert.NotNull(options);
Assert.IsType<GraphicsOptions>(options); Assert.IsType<GraphicsOptions>(options);
} }

3
tests/ImageSharp.Tests/Processing/BaseImageOperationsExtensionTest.cs

@ -1,6 +1,7 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System.ComponentModel.DataAnnotations;
using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing;
@ -25,7 +26,7 @@ namespace SixLabors.ImageSharp.Tests.Processing
this.source = new Image<Rgba32>(91 + 324, 123 + 56); this.source = new Image<Rgba32>(91 + 324, 123 + 56);
this.rect = new Rectangle(91, 123, 324, 56); // make this random? this.rect = new Rectangle(91, 123, 324, 56); // make this random?
this.internalOperations = new FakeImageOperationsProvider.FakeImageOperations<Rgba32>(this.source.GetConfiguration(), this.source, false); this.internalOperations = new FakeImageOperationsProvider.FakeImageOperations<Rgba32>(this.source.GetConfiguration(), this.source, false);
this.internalOperations.SetDefaultOptions(this.options); this.internalOperations.SetGraphicsOptions(this.options);
this.operations = this.internalOperations; this.operations = this.internalOperations;
} }

4
tests/ImageSharp.Tests/Processing/Filters/ContrastTest.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using Xunit; using Xunit;
@ -28,4 +28,4 @@ namespace SixLabors.ImageSharp.Tests.Processing.Effects
Assert.Equal(1.5F, processor.Amount); Assert.Equal(1.5F, processor.Amount);
} }
} }
} }

Loading…
Cancel
Save