ColorSchemeTests.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using System.Reflection;
  2. namespace Terminal.Gui.DrawingTests;
  3. public class ColorSchemeTests
  4. {
  5. [Fact]
  6. public void Colors_ColorSchemes_Built_Ins ()
  7. {
  8. Colors.Reset ();
  9. Dictionary<string, ColorScheme> schemes = Colors.ColorSchemes;
  10. Assert.NotNull (schemes);
  11. Assert.Equal (5, schemes.Count);
  12. Assert.True (schemes.ContainsKey ("TopLevel"));
  13. Assert.True (schemes.ContainsKey ("Base"));
  14. Assert.True (schemes.ContainsKey ("Dialog"));
  15. Assert.True (schemes.ContainsKey ("Menu"));
  16. Assert.True (schemes.ContainsKey ("Error"));
  17. }
  18. [Fact]
  19. public void Colors_ColorSchemes_Property_Has_Private_Setter ()
  20. {
  21. // Resharper Code Cleanup likes to remove the `private set; `
  22. // from the ColorSchemes property. This test will fail if
  23. // that happens.
  24. PropertyInfo property = typeof (Colors).GetProperty ("ColorSchemes");
  25. Assert.NotNull (property);
  26. Assert.NotNull (property.SetMethod);
  27. Assert.True (property.GetSetMethod (true).IsPrivate);
  28. }
  29. [Fact]
  30. public void ColorScheme_New ()
  31. {
  32. var scheme = new ColorScheme ();
  33. var lbl = new Label ();
  34. lbl.ColorScheme = scheme;
  35. lbl.Draw ();
  36. }
  37. [Fact]
  38. public void ColorScheme_BigConstructor ()
  39. {
  40. var a = new Attribute (1);
  41. var b = new Attribute (2);
  42. var c = new Attribute (3);
  43. var d = new Attribute (4);
  44. var e = new Attribute (5);
  45. var cs = new ColorScheme (
  46. normal: a,
  47. focus: b,
  48. hotNormal: c,
  49. disabled: d,
  50. hotFocus: e);
  51. Assert.Equal (a, cs.Normal);
  52. Assert.Equal (b, cs.Focus);
  53. Assert.Equal (c, cs.HotNormal);
  54. Assert.Equal (d, cs.Disabled);
  55. Assert.Equal (e, cs.HotFocus);
  56. }
  57. }