mirror of
https://github.com/SabreTools/SabreTools.Serialization.git
synced 2026-07-08 18:06:41 +00:00
Checkpoint reflection replacement
This commit is contained in:
@@ -1406,5 +1406,89 @@ namespace SabreTools.Metadata.Filter.Test
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Media
|
||||
|
||||
[Theory]
|
||||
[InlineData("media.md5", "md5")]
|
||||
[InlineData("media.name", "name")]
|
||||
[InlineData("media.sha1", "sha1")]
|
||||
[InlineData("media.sha256", "sha256")]
|
||||
[InlineData("media.spamsum", "spamsum")]
|
||||
public void Matches_Media(string itemField, string value)
|
||||
{
|
||||
var filter = new FilterObject(itemField, value, Operation.Equals);
|
||||
Media obj = new Media
|
||||
{
|
||||
MD5 = "md5",
|
||||
Name = "name",
|
||||
SHA1 = "sha1",
|
||||
SHA256 = "sha256",
|
||||
SpamSum = "spamsum",
|
||||
};
|
||||
|
||||
bool actual = filter.Matches(obj);
|
||||
Assert.True(actual);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Original
|
||||
|
||||
[Theory]
|
||||
[InlineData("original.content", "content")]
|
||||
[InlineData("original.value", "yes")]
|
||||
public void Matches_Original(string itemField, string value)
|
||||
{
|
||||
var filter = new FilterObject(itemField, value, Operation.Equals);
|
||||
Original obj = new Original
|
||||
{
|
||||
Content = "content",
|
||||
Value = true,
|
||||
};
|
||||
|
||||
bool actual = filter.Matches(obj);
|
||||
Assert.True(actual);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Part
|
||||
|
||||
[Theory]
|
||||
[InlineData("part.interface", "interface")]
|
||||
[InlineData("part.name", "name")]
|
||||
public void Matches_Part(string itemField, string value)
|
||||
{
|
||||
var filter = new FilterObject(itemField, value, Operation.Equals);
|
||||
Part obj = new Part
|
||||
{
|
||||
Interface = "interface",
|
||||
Name = "name",
|
||||
};
|
||||
|
||||
bool actual = filter.Matches(obj);
|
||||
Assert.True(actual);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Port
|
||||
|
||||
[Theory]
|
||||
[InlineData("port.tag", "tag")]
|
||||
public void Matches_Port(string itemField, string value)
|
||||
{
|
||||
var filter = new FilterObject(itemField, value, Operation.Equals);
|
||||
Port obj = new Port
|
||||
{
|
||||
Tag = "tag",
|
||||
};
|
||||
|
||||
bool actual = filter.Matches(obj);
|
||||
Assert.True(actual);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -478,6 +478,44 @@ namespace SabreTools.Metadata.Filter
|
||||
"year",
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// Known keys for Media
|
||||
/// </summary>
|
||||
private static readonly string[] _mediaKeys =
|
||||
[
|
||||
"md5",
|
||||
"name",
|
||||
"sha1",
|
||||
"sha256",
|
||||
"spamsum",
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// Known keys for Original
|
||||
/// </summary>
|
||||
private static readonly string[] _originalKeys =
|
||||
[
|
||||
"content",
|
||||
"value",
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// Known keys for Part
|
||||
/// </summary>
|
||||
private static readonly string[] _partKeys =
|
||||
[
|
||||
"interface",
|
||||
"name",
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// Known keys for Port
|
||||
/// </summary>
|
||||
private static readonly string[] _portKeys =
|
||||
[
|
||||
"tag",
|
||||
];
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
@@ -676,9 +714,15 @@ namespace SabreTools.Metadata.Filter
|
||||
"driver" => _driverKeys,
|
||||
"extension" => _extensionKeys,
|
||||
"feature" or "partfeature" => _featureKeys,
|
||||
"game" or "machine" or "resource" or "set" => _machineKeys,
|
||||
"header" => _headerKeys,
|
||||
"info" => _infoKeys,
|
||||
"input" => _inputKeys,
|
||||
"instance" => _instanceKeys,
|
||||
"media" => _mediaKeys,
|
||||
"original" => _originalKeys,
|
||||
"part" => _partKeys,
|
||||
"port" => _portKeys,
|
||||
_ => null,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user