BitmapOperationsUtilityTests.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System.Collections.Generic;
  2. using System.Windows.Media;
  3. using PixiEditor.Models.Controllers;
  4. using PixiEditor.Models.DataHolders;
  5. using PixiEditor.Models.Layers;
  6. using PixiEditor.Models.Position;
  7. using PixiEditor.Models.Tools;
  8. using Xunit;
  9. namespace PixiEditorTests.ModelsTests.ControllersTests
  10. {
  11. public class BitmapOperationsUtilityTests
  12. {
  13. [Fact]
  14. public void TestThatBitmapOperationsUtilityDeletesPixels()
  15. {
  16. BitmapOperationsUtility util = new BitmapOperationsUtility(new BitmapManager());
  17. Layer testLayer = new Layer("test layer", 10, 10);
  18. Coordinates[] cords = {new Coordinates(0, 0), new Coordinates(1, 1)};
  19. BitmapPixelChanges pixels = BitmapPixelChanges.FromSingleColoredArray(cords, Colors.Black);
  20. testLayer.SetPixels(pixels);
  21. util.DeletePixels(new []{testLayer}, cords);
  22. Assert.Equal(0, testLayer.GetPixel(0, 0).A);
  23. Assert.Equal(0, testLayer.GetPixel(1, 1).A);
  24. }
  25. [StaFact]
  26. public void TestThatBitmapOperationsUtilityExecutesPenToolProperly()
  27. {
  28. BitmapManager manager = new BitmapManager
  29. {
  30. ActiveDocument = new Document(10, 10),
  31. PrimaryColor = Colors.Black,
  32. };
  33. manager.AddNewLayer("Test layer", 10, 10);
  34. BitmapOperationsUtility util = new BitmapOperationsUtility(manager);
  35. List<Coordinates> mouseMove = new List<Coordinates>(new [] {new Coordinates(0,0)});
  36. util.ExecuteTool(new Coordinates(0,0), mouseMove, new MockedSinglePixelPen());
  37. Assert.Equal(manager.ActiveLayer.GetPixel(0,0), Colors.Black);
  38. }
  39. }
  40. }