Przeglądaj źródła

Fixed tests and added null check for DeletePixels

flabbet 4 lat temu
rodzic
commit
915663ce57

+ 5 - 0
PixiEditor/Models/Controllers/BitmapOperationsUtility.cs

@@ -29,6 +29,11 @@ namespace PixiEditor.Models.Controllers
 
         public void DeletePixels(Layer[] layers, Coordinates[] pixels)
         {
+            if (Manager.ActiveDocument == null)
+            {
+                return;
+            }
+
             BitmapPixelChanges changes = BitmapPixelChanges.FromSingleColoredArray(pixels, Color.FromArgb(0, 0, 0, 0));
             Dictionary<Layer, Color[]> oldValues = BitmapUtils.GetPixelsForSelection(layers, pixels);
             LayerChange[] old = new LayerChange[layers.Length];

+ 1 - 0
PixiEditorTests/ModelsTests/ControllersTests/BitmapOperationsUtilityTests.cs

@@ -14,6 +14,7 @@ namespace PixiEditorTests.ModelsTests.ControllersTests
         public void TestThatBitmapOperationsUtilityDeletesPixels()
         {
             BitmapOperationsUtility util = new BitmapOperationsUtility(new BitmapManager());
+            util.Manager.ActiveDocument = new Document(10, 10);
 
             Layer testLayer = new Layer("test layer", 10, 10);
             Coordinates[] cords = { new Coordinates(0, 0), new Coordinates(1, 1) };

+ 1 - 1
PixiEditorTests/ViewModelsTests/ViewModelMainTests.cs

@@ -18,7 +18,7 @@ namespace PixiEditorTests.ViewModelsTests
         {
             ViewModelMain viewModel = new ViewModelMain();
 
-            Assert.Equal(viewModel, UndoManager.MainRoot);
+            Assert.Equal(viewModel.UndoSubViewModel, UndoManager.MainRoot);
             Assert.NotNull(viewModel.ChangesController);
             Assert.NotNull(viewModel.ShortcutController);
             Assert.NotEmpty(viewModel.ShortcutController.Shortcuts);