BrightnessToolTests.cs 1.2 KB

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