SplitViewTests.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using Xunit;
  5. namespace Avalonia.Controls.UnitTests
  6. {
  7. public class SplitViewTests
  8. {
  9. [Fact]
  10. public void SplitView_PaneOpening_Should_Fire_Before_PaneOpened()
  11. {
  12. var splitView = new SplitView();
  13. bool handledOpening = false;
  14. splitView.PaneOpening += (x, e) =>
  15. {
  16. handledOpening = true;
  17. };
  18. splitView.PaneOpened += (x, e) =>
  19. {
  20. Assert.True(handledOpening);
  21. };
  22. splitView.IsPaneOpen = true;
  23. }
  24. [Fact]
  25. public void SplitView_PaneClosing_Should_Fire_Before_PaneClosed()
  26. {
  27. var splitView = new SplitView();
  28. splitView.IsPaneOpen = true;
  29. bool handledClosing = false;
  30. splitView.PaneClosing += (x, e) =>
  31. {
  32. handledClosing = true;
  33. };
  34. splitView.PaneClosed += (x, e) =>
  35. {
  36. Assert.True(handledClosing);
  37. };
  38. splitView.IsPaneOpen = false;
  39. }
  40. [Fact]
  41. public void SplitView_Cancel_Close_Should_Prevent_Pane_From_Closing()
  42. {
  43. var splitView = new SplitView();
  44. splitView.IsPaneOpen = true;
  45. splitView.PaneClosing += (x, e) =>
  46. {
  47. e.Cancel = true;
  48. };
  49. splitView.IsPaneOpen = false;
  50. Assert.True(splitView.IsPaneOpen);
  51. }
  52. }
  53. }