GlyphTests.cs 913 B

1234567891011121314151617181920212223242526272829
  1. using System.Reflection;
  2. using System.Text;
  3. using System.Text.Json;
  4. namespace Terminal.Gui.DrawingTests;
  5. public class GlyphTests
  6. {
  7. [Fact]
  8. public void Default_GlyphDefinitions_Deserialize ()
  9. {
  10. var defs = new GlyphDefinitions ();
  11. // enumerate all properties in GlyphDefinitions
  12. foreach (PropertyInfo prop in typeof (GlyphDefinitions).GetProperties ())
  13. {
  14. if (prop.PropertyType == typeof (Rune))
  15. {
  16. // Act
  17. var rune = (Rune)prop.GetValue (defs);
  18. string json = JsonSerializer.Serialize (rune, ConfigurationManager._serializerOptions);
  19. var deserialized = JsonSerializer.Deserialize<Rune> (json, ConfigurationManager._serializerOptions);
  20. // Assert
  21. Assert.Equal (((Rune)prop.GetValue (defs)).Value, deserialized.Value);
  22. }
  23. }
  24. }
  25. }