Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

68 строки
2.6KB

  1. using EnvelopeRenderer.Desktop.Core.Design;
  2. namespace EnvelopeRenderer.Desktop.Tests;
  3. public class SelectionCyclerTests
  4. {
  5. private static readonly Guid A = Guid.Parse("00000000-0000-0000-0000-00000000000a");
  6. private static readonly Guid B = Guid.Parse("00000000-0000-0000-0000-00000000000b");
  7. private static readonly Guid C = Guid.Parse("00000000-0000-0000-0000-00000000000c");
  8. private static SelectionCycler.Item[] Items() => new[]
  9. {
  10. new SelectionCycler.Item(C, ZOrder: 2, X: 0, Y: 0),
  11. new SelectionCycler.Item(A, ZOrder: 0, X: 0, Y: 0),
  12. new SelectionCycler.Item(B, ZOrder: 1, X: 0, Y: 0),
  13. };
  14. [Fact]
  15. public void Forward_WalksBottomToTopByZOrder_AndWraps()
  16. {
  17. Assert.Equal(A, SelectionCycler.Next(Items(), null, forward: true));
  18. Assert.Equal(B, SelectionCycler.Next(Items(), A, forward: true));
  19. Assert.Equal(C, SelectionCycler.Next(Items(), B, forward: true));
  20. Assert.Equal(A, SelectionCycler.Next(Items(), C, forward: true));
  21. }
  22. [Fact]
  23. public void Backward_WalksTopToBottom_AndWraps_StartingAtTheLastItem()
  24. {
  25. Assert.Equal(C, SelectionCycler.Next(Items(), null, forward: false));
  26. Assert.Equal(B, SelectionCycler.Next(Items(), C, forward: false));
  27. Assert.Equal(A, SelectionCycler.Next(Items(), B, forward: false));
  28. Assert.Equal(C, SelectionCycler.Next(Items(), A, forward: false));
  29. }
  30. [Fact]
  31. public void SameZOrder_VisitsTopToBottomThenLeftToRight()
  32. {
  33. var items = new[]
  34. {
  35. new SelectionCycler.Item(A, 0, X: 50, Y: 10),
  36. new SelectionCycler.Item(B, 0, X: 10, Y: 100),
  37. new SelectionCycler.Item(C, 0, X: 10, Y: 10),
  38. };
  39. Assert.Equal(B, SelectionCycler.Next(items, null, forward: true)); // highest on the page first
  40. Assert.Equal(C, SelectionCycler.Next(items, B, forward: true)); // then the lower-left one
  41. Assert.Equal(A, SelectionCycler.Next(items, C, forward: true));
  42. }
  43. [Fact]
  44. public void UnknownCurrentSelection_BehavesLikeNoSelection()
  45. => Assert.Equal(A, SelectionCycler.Next(Items(), Guid.NewGuid(), forward: true));
  46. [Fact]
  47. public void NoItems_ReturnsNull()
  48. => Assert.Null(SelectionCycler.Next(Array.Empty<SelectionCycler.Item>(), null, forward: true));
  49. [Fact]
  50. public void SingleItem_StaysOnIt()
  51. {
  52. var items = new[] { new SelectionCycler.Item(A, 0, 0, 0) };
  53. Assert.Equal(A, SelectionCycler.Next(items, A, forward: true));
  54. Assert.Equal(A, SelectionCycler.Next(items, A, forward: false));
  55. }
  56. }

Powered by TurnKey Linux.