mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
* Refactored test namespaces. Moved some tests that were in wrong project. Code cleanup * Parrallel -> Parallel
34 lines
1.2 KiB
C#
34 lines
1.2 KiB
C#
#nullable enable
|
|
using System.Text.Json;
|
|
|
|
namespace UnitTests_Parallelizable.ConfigurationTests;
|
|
|
|
public class ScopeJsonConverterTests
|
|
{
|
|
[Theory]
|
|
[InlineData ("\"ConfigurationManager.ThrowOnJsonErrors\":true")]
|
|
[InlineData ("\"Key.Separator\":\"@\"")]
|
|
[InlineData ("\"Themes\":[]")]
|
|
[InlineData ("\"Themes\":[{\"themeName\":{}}]")]
|
|
[InlineData ("\"Themes\":[{\"themeName\":{\"Dialog.DefaultButtonAlignment\":\"End\"}}]")]
|
|
public void RoundTripConversion_Property_Positive (string configPropertyJson)
|
|
{
|
|
// Arrange
|
|
string scopeJson = $"{{{configPropertyJson}}}";
|
|
|
|
// Act
|
|
SettingsScope? deserialized = JsonSerializer.Deserialize<SettingsScope> (scopeJson, ConfigurationManager.SerializerContext.Options);
|
|
|
|
string? json = JsonSerializer.Serialize<SettingsScope> (deserialized!, ConfigurationManager.SerializerContext.Options);
|
|
|
|
// Strip all whitespace
|
|
json = json.Replace (" ", string.Empty);
|
|
json = json.Replace ("\n", string.Empty);
|
|
json = json.Replace ("\r", string.Empty);
|
|
json = json.Replace ("\t", string.Empty);
|
|
|
|
// Assert
|
|
Assert.Contains (configPropertyJson, json);
|
|
}
|
|
}
|