mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-27 00:07:58 +01:00
* Refactored test namespaces. Moved some tests that were in wrong project. Code cleanup * Parrallel -> Parallel
58 lines
1.9 KiB
C#
58 lines
1.9 KiB
C#
using System.Text;
|
|
using System.Text.Encodings.Web;
|
|
using System.Text.Json;
|
|
using System.Text.Unicode;
|
|
|
|
namespace UnitTests.ConfigurationTests;
|
|
|
|
public class KeyJsonConverterTests
|
|
{
|
|
|
|
[Fact]
|
|
public void Separator_Property_Set_Changes_Serialization_Format ()
|
|
{
|
|
Rune savedSeparator = Key.Separator;
|
|
|
|
// Act
|
|
// NOTE: This means this test can't be parallelized
|
|
Key.Separator = (Rune)'*';
|
|
string json = JsonSerializer.Serialize (Key.Separator, ConfigurationManager.SerializerContext.Options);
|
|
|
|
// Assert
|
|
Assert.Equal ("\"*\"", json);
|
|
Key.Separator = savedSeparator;
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData ('A', '+', "\"Ctrl+Alt+A\"")]
|
|
[InlineData ('A', '-', "\"Ctrl+Alt+A\"")]
|
|
[InlineData ('A', '*', "\"Ctrl+Alt+A\"")]
|
|
[InlineData ('A', '@', "\"Ctrl+Alt+A\"")]
|
|
[InlineData ('A', '+', "\"Ctrl@Alt@A\"")]
|
|
[InlineData ('A', '-', "\"Ctrl@Alt@A\"")]
|
|
[InlineData ('A', '*', "\"Ctrl@Alt@A\"")]
|
|
[InlineData ('A', '@', "\"Ctrl@Alt@A\"")]
|
|
[InlineData ('+', '+', "\"Ctrl+Alt++\"")]
|
|
[InlineData ('+', '-', "\"Ctrl+Alt++\"")]
|
|
[InlineData ('+', '*', "\"Ctrl+Alt++\"")]
|
|
[InlineData ('+', '@', "\"Ctrl+Alt++\"")]
|
|
[InlineData ('+', '+', "\"Ctrl@Alt@+\"")]
|
|
[InlineData ('+', '-', "\"Ctrl@Alt@+\"")]
|
|
[InlineData ('+', '*', "\"Ctrl@Alt@+\"")]
|
|
[InlineData ('+', '@', "\"Ctrl@Alt@+\"")]
|
|
public void Separator_Property_Set_Deserialization_Works_With_Any (char keyChar, char separator, string json)
|
|
{
|
|
Rune savedSeparator = Key.Separator;
|
|
|
|
// Act
|
|
// NOTE: This means this test can't be parallelized
|
|
Key.Separator = (Rune)separator;
|
|
|
|
Key deserializedKey = JsonSerializer.Deserialize<Key> (json, ConfigurationManager.SerializerContext.Options);
|
|
|
|
Key expectedKey = new Key ((KeyCode)keyChar).WithCtrl.WithAlt;
|
|
// Assert
|
|
Assert.Equal (expectedKey, deserializedKey);
|
|
Key.Separator = savedSeparator;
|
|
}
|
|
} |