BitmapPixelChangesTests.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using PixiEditor.Models.DataHolders;
  2. using PixiEditor.Models.Position;
  3. using SkiaSharp;
  4. using Xunit;
  5. namespace PixiEditorTests.ModelsTests.DataHoldersTests
  6. {
  7. public class BitmapPixelChangesTests
  8. {
  9. [Fact]
  10. public void TestThatFromSingleColoredArrayCreatesCorrectArray()
  11. {
  12. Coordinates[] cords = { new Coordinates(0, 0), new Coordinates(1, 0), new Coordinates(3, 2) };
  13. BitmapPixelChanges bmpChanges = BitmapPixelChanges.FromSingleColoredArray(cords, SKColors.Lime);
  14. Assert.All(bmpChanges.ChangedPixels.Values, changeColor => Assert.Equal(SKColors.Lime, changeColor));
  15. Assert.True(bmpChanges.WasBuiltAsSingleColored);
  16. }
  17. [Fact]
  18. public void TestThatCombineCombineOverrideCombinesValues()
  19. {
  20. Coordinates[] cords1 = { new Coordinates(0, 0), new Coordinates(1, 0), new Coordinates(3, 2) };
  21. Coordinates[] cords2 = { new Coordinates(3, 2), new Coordinates(0, 0), new Coordinates(5, 5) };
  22. BitmapPixelChanges changes = BitmapPixelChanges.FromSingleColoredArray(cords1, SKColors.Lime);
  23. BitmapPixelChanges changes2 = BitmapPixelChanges.FromSingleColoredArray(cords2, SKColors.Red);
  24. BitmapPixelChanges output = BitmapPixelChanges.CombineOverride(new[] { changes, changes2 });
  25. Assert.Equal(4, output.ChangedPixels.Count);
  26. Assert.Equal(SKColors.Red, output.ChangedPixels[new Coordinates(3, 2)]);
  27. Assert.Equal(SKColors.Red, output.ChangedPixels[new Coordinates(0, 0)]);
  28. Assert.Equal(SKColors.Lime, output.ChangedPixels[new Coordinates(1, 0)]);
  29. }
  30. }
  31. }