ColorPickerTests.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using UnitTests;
  2. namespace UnitTests_Parallelizable.ViewsTests;
  3. /// <summary>
  4. /// Pure unit tests for <see cref="ColorPicker"/> that don't require Application.Driver or View context.
  5. /// These tests can run in parallel without interference.
  6. /// </summary>
  7. public class ColorPickerTests : FakeDriverBase
  8. {
  9. [Fact]
  10. public void ColorPicker_ChangedEvent_Fires ()
  11. {
  12. Color newColor = default;
  13. var count = 0;
  14. var cp = new ColorPicker ();
  15. cp.ColorChanged += (s, e) =>
  16. {
  17. count++;
  18. newColor = e.Result;
  19. Assert.Equal (cp.SelectedColor, e.Result);
  20. };
  21. cp.SelectedColor = new (1, 2, 3);
  22. Assert.Equal (1, count);
  23. Assert.Equal (new (1, 2, 3), newColor);
  24. cp.SelectedColor = new (2, 3, 4);
  25. Assert.Equal (2, count);
  26. Assert.Equal (new (2, 3, 4), newColor);
  27. // Set to same value
  28. cp.SelectedColor = new (2, 3, 4);
  29. // Should have no effect
  30. Assert.Equal (2, count);
  31. }
  32. }