BrightnessToolTests.cs 1.2 KB

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