BitmapOperationsUtilityTests.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 PixiEditorTests.ModelsTests.ColorsTests;
  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. util.Manager.ActiveDocument = new Document(10, 10);
  18. Layer testLayer = new Layer("test layer", 10, 10);
  19. Coordinates[] cords = { new Coordinates(0, 0), new Coordinates(1, 1) };
  20. BitmapPixelChanges pixels = BitmapPixelChanges.FromSingleColoredArray(cords, ExtendedColorTests.black);
  21. testLayer.SetPixels(pixels);
  22. util.DeletePixels(new[] { testLayer }, cords);
  23. Assert.Equal(0, testLayer.GetPixel(0, 0).Alpha);
  24. Assert.Equal(0, testLayer.GetPixel(1, 1).Alpha);
  25. }
  26. [StaFact]
  27. public void TestThatBitmapOperationsUtilityExecutesPenToolProperly()
  28. {
  29. BitmapManager manager = new BitmapManager
  30. {
  31. ActiveDocument = new Document(10, 10),
  32. PrimaryColor = ExtendedColorTests.black
  33. };
  34. manager.ActiveDocument.AddNewLayer("Test layer", 10, 10);
  35. BitmapOperationsUtility util = new BitmapOperationsUtility(manager);
  36. List<Coordinates> mouseMove = new List<Coordinates>(new[] { new Coordinates(0, 0) });
  37. util.ExecuteTool(new Coordinates(0, 0), mouseMove, new MockedSinglePixelPenTool());
  38. Assert.Equal(manager.ActiveLayer.GetPixel(0, 0), ExtendedColorTests.black);
  39. }
  40. }
  41. }