ColorSchemeJsonConverterTests.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using System.Text.Json;
  2. namespace Terminal.Gui.ConfigurationTests;
  3. public class ColorSchemeJsonConverterTests
  4. {
  5. //string json = @"
  6. // {
  7. // ""ColorSchemes"": {
  8. // ""Base"": {
  9. // ""normal"": {
  10. // ""foreground"": ""White"",
  11. // ""background"": ""Blue""
  12. // },
  13. // ""focus"": {
  14. // ""foreground"": ""Black"",
  15. // ""background"": ""Gray""
  16. // },
  17. // ""hotNormal"": {
  18. // ""foreground"": ""BrightCyan"",
  19. // ""background"": ""Blue""
  20. // },
  21. // ""hotFocus"": {
  22. // ""foreground"": ""BrightBlue"",
  23. // ""background"": ""Gray""
  24. // },
  25. // ""disabled"": {
  26. // ""foreground"": ""DarkGray"",
  27. // ""background"": ""Blue""
  28. // }
  29. // }
  30. // }
  31. // }";
  32. [Fact]
  33. [AutoInitShutdown]
  34. public void TestColorSchemesSerialization ()
  35. {
  36. // Arrange
  37. var expectedColorScheme = new ColorScheme
  38. {
  39. Normal = new Attribute (Color.White, Color.Blue),
  40. Focus = new Attribute (Color.Black, Color.Gray),
  41. HotNormal = new Attribute (Color.BrightCyan, Color.Blue),
  42. HotFocus = new Attribute (Color.BrightBlue, Color.Gray),
  43. Disabled = new Attribute (Color.DarkGray, Color.Blue)
  44. };
  45. string serializedColorScheme =
  46. JsonSerializer.Serialize (expectedColorScheme, ConfigurationManagerTests._jsonOptions);
  47. // Act
  48. var actualColorScheme =
  49. JsonSerializer.Deserialize<ColorScheme> (serializedColorScheme, ConfigurationManagerTests._jsonOptions);
  50. // Assert
  51. Assert.Equal (expectedColorScheme, actualColorScheme);
  52. }
  53. }