1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Windows;
- using System.Windows.Media;
- using PixiEditor;
- using PixiEditor.Models.Layers;
- using PixiEditor.Models.Position;
- using PixiEditor.Models.Tools.Tools;
- using Xunit;
- namespace PixiEditorTests.ModelsTests.ToolsTests
- {
- public class BrightnessToolTests
- {
- public BrightnessToolTests()
- {
- if (Application.Current == null)
- {
- var app = new App();
- app.InitializeComponent();
- }
- }
- [StaTheory]
- [InlineData(5, 12, 12, 12)]
- [InlineData(-5, 242, 242, 242)]
- // If correction factor is negative, testing color will be white, otherwise black
- public void TestThatBrightnessToolChangesPixelBrightness(float correctionFactor, byte expectedR, byte expectedG, byte expectedB)
- {
- Color expectedColor = Color.FromRgb(expectedR, expectedG, expectedB);
- BrightnessTool tool = new BrightnessTool();
- Layer layer = new Layer("test", 1, 1);
- layer.SetPixel(new Coordinates(0,0), correctionFactor < 0 ? Colors.White : Colors.Black);
- var changes = tool.ChangeBrightness(layer, new Coordinates(0, 0),1,correctionFactor);
- layer.SetPixels(changes);
- Assert.Equal(expectedColor,layer.GetPixel(0,0));
- }
- }
- }
|