BitmapOperationsUtilityTests.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 Xunit;
  8. namespace PixiEditorTests.ModelsTests.ControllersTests
  9. {
  10. public class BitmapOperationsUtilityTests
  11. {
  12. [Fact]
  13. public void TestThatBitmapOperationsUtilityDeletesPixels()
  14. {
  15. BitmapOperationsUtility util = new BitmapOperationsUtility(new BitmapManager());
  16. util.Manager.ActiveDocument = new Document(10, 10);
  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. }