BrightnessToolTests.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. public class BrightnessToolTests
  14. {
  15. public BrightnessToolTests()
  16. {
  17. if (Application.Current == null)
  18. {
  19. var app = new App();
  20. app.InitializeComponent();
  21. }
  22. }
  23. [StaTheory]
  24. [InlineData(5, 12, 12, 12)]
  25. [InlineData(-5, 242, 242, 242)]
  26. // If correction factor is negative, testing color will be white, otherwise black
  27. public void TestThatBrightnessToolChangesPixelBrightness(float correctionFactor, byte expectedR, byte expectedG, byte expectedB)
  28. {
  29. Color expectedColor = Color.FromRgb(expectedR, expectedG, expectedB);
  30. BrightnessTool tool = new BrightnessTool();
  31. Layer layer = new Layer("test", 1, 1);
  32. layer.SetPixel(new Coordinates(0,0), correctionFactor < 0 ? Colors.White : Colors.Black);
  33. var changes = tool.ChangeBrightness(layer, new Coordinates(0, 0),1,correctionFactor);
  34. layer.SetPixels(changes);
  35. Assert.Equal(expectedColor,layer.GetPixel(0,0));
  36. }
  37. }
  38. }