SelectionTests.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Windows.Media.Imaging;
  5. using PixiEditor.Models.DataHolders;
  6. using PixiEditor.Models.Enums;
  7. using PixiEditor.Models.Position;
  8. using Xunit;
  9. namespace PixiEditorTests.ModelsTests.DataHoldersTests
  10. {
  11. public class SelectionTests
  12. {
  13. [Fact]
  14. public void TestThatSetSelectionNewSetsCorrectSelection()
  15. {
  16. Selection selection = new Selection(Array.Empty<Coordinates>());
  17. Coordinates[] points = {new Coordinates(0, 0), new Coordinates(1, 1)};
  18. selection.SetSelection(points, SelectionType.New);
  19. selection.SetSelection(points, SelectionType.New); //Doing it twice, to check if it sets every time properly
  20. Assert.Equal(points.Length, selection.SelectedPoints.Count);
  21. }
  22. [Fact]
  23. public void TestThatSetSelectionAddSetsCorrectSelection()
  24. {
  25. Selection selection = new Selection(Array.Empty<Coordinates>());
  26. Coordinates[] points = { new Coordinates(0, 0), new Coordinates(1, 1) };
  27. Coordinates[] points2 = { new Coordinates(2, 4), new Coordinates(5, 7) };
  28. selection.SetSelection(points, SelectionType.Add);
  29. selection.SetSelection(points2, SelectionType.Add); //Doing it twice, to check if it sets every time properly
  30. Assert.Equal(points.Length + points2.Length, selection.SelectedPoints.Count);
  31. }
  32. [Fact]
  33. public void TestThatSetSelectionSubtractSetsCorrectSelection()
  34. {
  35. Selection selection = new Selection(Array.Empty<Coordinates>());
  36. Coordinates[] points = { new Coordinates(0, 0), new Coordinates(1, 1) };
  37. Coordinates[] points2 = { new Coordinates(1, 1)};
  38. selection.SetSelection(points, SelectionType.Add);
  39. selection.SetSelection(points2, SelectionType.Subtract); //Doing it twice, to check if it sets every time properly
  40. Assert.Single(selection.SelectedPoints);
  41. }
  42. [Fact]
  43. public void TestClearWorks()
  44. {
  45. Selection selection = new Selection(new []{new Coordinates(0,0), new Coordinates(5,7)});
  46. selection.Clear();
  47. Assert.Empty(selection.SelectedPoints);
  48. Assert.Equal(0,selection.SelectionLayer.Width + selection.SelectionLayer.Height);
  49. }
  50. }
  51. }