RegParser/RegParserDotNet.Tests/REG_SZ.cs
Pat Hartl 690e1c59e0 Rewrote regex patterns
The parser was not working well with binary data or properties that had blank values. The regex detection was overhauled to support these.
2023-12-07 01:27:15 -06:00

41 lines
1.4 KiB
C#

using Xunit;
namespace RegParserDotNet.Tests
{
public class REG_SZ
{
public const string ExportWithQuotes =
@"[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\New World Computing\Heroes of Might and Magic® III\1.0]
""Test \""Thing\""""=""With a value!\""Test\""""";
public const string ExportWithPathValue =
@"[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Chaos-League-MS]
@=""C:\\Games\\Chaos League""";
public const string ExportWithBlank =
@"[HKEY_CURRENT_USER\Software\Cavedog Entertainment\Total Annihilation]
""Password""=""""";
[Theory]
[InlineData(ExportWithQuotes, "Test \"Thing\"", "With a value!\"Test\"")]
[InlineData(ExportWithPathValue, "@", "C:\\Games\\Chaos League")]
[InlineData(ExportWithBlank, "Password", "")]
public void PropertyIsParseable(string input, string expectedProperty, string expectedValue)
{
var parser = new RegParser();
var keys = parser.Parse(input);
Assert.NotNull(keys);
Assert.NotEmpty(keys);
Assert.Equal(2, keys.Count());
Assert.Equal(keys.First().Path, keys.Last().Path);
var key = keys.Last();
Assert.Equal(RegistryValueType.REG_SZ, key.Type);
Assert.Equal(expectedProperty, key.Property);
Assert.Equal(expectedValue, (string)key.Value);
}
}
}