SchemeTests.GetAttributeForRoleAlgorithmTests.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. using Xunit;
  2. namespace UnitTests_Parallelizable.DrawingTests;
  3. public class SchemeGetAttributeForRoleAlgorithmTests
  4. {
  5. [Fact]
  6. public void Normal_Is_Always_Explicit ()
  7. {
  8. Attribute normal = new ("Red", "Blue");
  9. Scheme scheme = new (normal);
  10. Assert.Equal (normal, scheme.GetAttributeForRole (VisualRole.Normal));
  11. }
  12. [Fact]
  13. public void Focus_Derived_From_Normal_Swaps_FgBg ()
  14. {
  15. Attribute normal = new ("Red", "Blue");
  16. Scheme scheme = new (normal);
  17. Attribute focus = scheme.GetAttributeForRole (VisualRole.Focus);
  18. Assert.False (scheme.TryGetExplicitlySetAttributeForRole (VisualRole.Focus, out _));
  19. Assert.Equal (normal.Background, focus.Foreground);
  20. Assert.Equal (normal.Foreground, focus.Background);
  21. }
  22. //[Fact]
  23. //public void Highlight_Derived_From_Normal_HighlightColor ()
  24. //{
  25. // Attribute normal = new ("Red", "Blue");
  26. // Scheme scheme = new (normal);
  27. // Attribute highlight = scheme.GetAttributeForRole (VisualRole.Highlight);
  28. // Assert.False (scheme.TryGetExplicitlySetAttributeForRole (VisualRole.Highlight, out _));
  29. // Assert.Equal (normal.Background.GetHighlightColor (), highlight.Background);
  30. //}
  31. //[Fact]
  32. //public void Editable_Derived_From_Normal_LightYellow_Fg ()
  33. //{
  34. // Attribute normal = new ("Red", "Blue");
  35. // Scheme scheme = new (normal);
  36. // Attribute editable = scheme.GetAttributeForRole (VisualRole.Editable);
  37. // Assert.False (scheme.TryGetExplicitlySetAttributeForRole (VisualRole.Editable, out _));
  38. // Assert.Equal (new Color ("LightYellow"), editable.Foreground);
  39. //}
  40. //[Fact]
  41. //public void ReadOnly_Derived_From_Editable_Italic ()
  42. //{
  43. // Attribute normal = new ("Red", "Blue");
  44. // Scheme scheme = new (normal);
  45. // Attribute readOnly = scheme.GetAttributeForRole (VisualRole.ReadOnly);
  46. // Attribute editable = scheme.GetAttributeForRole (VisualRole.Editable);
  47. // Assert.False (scheme.TryGetExplicitlySetAttributeForRole (VisualRole.ReadOnly, out _));
  48. // Assert.Equal (editable.Foreground, readOnly.Foreground);
  49. // Assert.True (readOnly.Style.HasFlag (TextStyle.Italic));
  50. //}
  51. //[Fact]
  52. //public void Disabled_Derived_From_Normal_Faint ()
  53. //{
  54. // Attribute normal = new ("Red", "Blue");
  55. // Scheme scheme = new (normal);
  56. // Attribute disabled = scheme.GetAttributeForRole (VisualRole.Disabled);
  57. // Assert.False (scheme.TryGetExplicitlySetAttributeForRole (VisualRole.Disabled, out _));
  58. // Assert.True (disabled.Style.HasFlag (TextStyle.Faint));
  59. //}
  60. [Fact]
  61. public void Active_Derived_Correctly ()
  62. {
  63. Attribute normal = new ("Red", "Blue");
  64. Scheme scheme = new (normal);
  65. Assert.False (scheme.TryGetExplicitlySetAttributeForRole (VisualRole.Active, out _));
  66. Attribute active = scheme.GetAttributeForRole (VisualRole.Active);
  67. Attribute focus = scheme.GetAttributeForRole (VisualRole.Focus);
  68. Assert.True (active.Style.HasFlag (TextStyle.Bold));
  69. //Assert.Equal (active.Foreground, focus.Foreground);
  70. //Assert.Equal (active.Background, active.Background);
  71. }
  72. [Fact]
  73. public void HotNormal_Derived_From_Normal_Underline ()
  74. {
  75. Attribute normal = new ("Red", "Blue");
  76. Scheme scheme = new (normal);
  77. Attribute hotNormal = scheme.GetAttributeForRole (VisualRole.HotNormal);
  78. Assert.False (scheme.TryGetExplicitlySetAttributeForRole (VisualRole.HotNormal, out _));
  79. Assert.True (hotNormal.Style.HasFlag (TextStyle.Underline));
  80. }
  81. [Fact]
  82. public void HotFocus_Derived_From_Focus_Underline ()
  83. {
  84. Attribute normal = new ("Red", "Blue");
  85. Scheme scheme = new (normal);
  86. Attribute hotFocus = scheme.GetAttributeForRole (VisualRole.HotFocus);
  87. Assert.False (scheme.TryGetExplicitlySetAttributeForRole (VisualRole.HotFocus, out _));
  88. Attribute focus = scheme.GetAttributeForRole (VisualRole.Focus);
  89. Assert.True (hotFocus.Style.HasFlag (TextStyle.Underline));
  90. Assert.Equal (focus.Foreground, hotFocus.Foreground);
  91. Assert.Equal (focus.Background, hotFocus.Background);
  92. }
  93. [Fact]
  94. public void HotActive_Derived_From_Active_Underline ()
  95. {
  96. Attribute normal = new ("Red", "Blue");
  97. Scheme scheme = new (normal);
  98. Attribute hotActive = scheme.GetAttributeForRole (VisualRole.HotActive);
  99. Assert.False (scheme.TryGetExplicitlySetAttributeForRole (VisualRole.HotActive, out _));
  100. Attribute active = scheme.GetAttributeForRole (VisualRole.Active);
  101. Assert.True (hotActive.Style.HasFlag (TextStyle.Underline));
  102. Assert.Equal (active.Foreground, hotActive.Foreground);
  103. Assert.Equal (active.Background, hotActive.Background);
  104. }
  105. }