BrightnessToolTests.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. using System.Windows.Media;
  2. using PixiEditor.Models.Layers;
  3. using PixiEditor.Models.Position;
  4. using PixiEditor.Models.Tools.Tools;
  5. using Xunit;
  6. namespace PixiEditorTests.ModelsTests.ToolsTests
  7. {
  8. [Collection("Application collection")]
  9. public class BrightnessToolTests
  10. {
  11. [StaTheory]
  12. [InlineData(5, 12, 12, 12)]
  13. [InlineData(-5, 242, 242, 242)]
  14. // If correction factor is negative, testing color will be white, otherwise black
  15. public void TestThatBrightnessToolChangesPixelBrightness(float correctionFactor, byte expectedR, byte expectedG, byte expectedB)
  16. {
  17. Color expectedColor = Color.FromRgb(expectedR, expectedG, expectedB);
  18. BrightnessTool tool = new BrightnessTool();
  19. Layer layer = new Layer("test", 1, 1);
  20. layer.SetPixel(new Coordinates(0, 0), correctionFactor < 0 ? Colors.White : Colors.Black);
  21. PixiEditor.Models.DataHolders.BitmapPixelChanges changes = tool.ChangeBrightness(layer, new Coordinates(0, 0), 1, correctionFactor);
  22. layer.SetPixels(changes);
  23. Assert.Equal(expectedColor, layer.GetPixel(0, 0));
  24. }
  25. }
  26. }