mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Add ContainsWritable tests
This commit is contained in:
@@ -1514,7 +1514,35 @@ namespace SabreTools.DatFiles.Test
|
|||||||
|
|
||||||
#region ContainsWritable
|
#region ContainsWritable
|
||||||
|
|
||||||
// TODO: Write ContainsWritable tests
|
[Fact]
|
||||||
|
public void ContainsWritable_Empty_True()
|
||||||
|
{
|
||||||
|
List<DatItem> datItems = [];
|
||||||
|
DatFile datFile = new Formats.Logiqx(null, deprecated: false);
|
||||||
|
|
||||||
|
bool actual = datFile.ContainsWritable(datItems);
|
||||||
|
Assert.True(actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void ContainsWritable_NoWritable_False()
|
||||||
|
{
|
||||||
|
List<DatItem> datItems = [new Blank()];
|
||||||
|
DatFile datFile = new Formats.Logiqx(null, deprecated: false);
|
||||||
|
|
||||||
|
bool actual = datFile.ContainsWritable(datItems);
|
||||||
|
Assert.False(actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void ContainsWritable_Writable_True()
|
||||||
|
{
|
||||||
|
List<DatItem> datItems = [new Rom()];
|
||||||
|
DatFile datFile = new Formats.Logiqx(null, deprecated: false);
|
||||||
|
|
||||||
|
bool actual = datFile.ContainsWritable(datItems);
|
||||||
|
Assert.True(actual);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@@ -431,15 +431,15 @@ namespace SabreTools.DatFiles
|
|||||||
protected internal virtual List<string>? GetMissingRequiredFields(DatItem datItem) => null;
|
protected internal virtual List<string>? GetMissingRequiredFields(DatItem datItem) => null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get if a machine contains any writable items
|
/// Get if a list contains any writable items
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="datItems">DatItems to check</param>
|
/// <param name="datItems">DatItems to check</param>
|
||||||
/// <returns>True if the machine contains at least one writable item, false otherwise</returns>
|
/// <returns>True if the list contains at least one writable item, false otherwise</returns>
|
||||||
/// <remarks>Empty machines are kept with this</remarks>
|
/// <remarks>Empty list are kept with this</remarks>
|
||||||
protected internal bool ContainsWritable(List<DatItem> datItems)
|
protected internal bool ContainsWritable(List<DatItem> datItems)
|
||||||
{
|
{
|
||||||
// Empty machines are considered writable
|
// Empty list are considered writable
|
||||||
if (datItems == null || datItems.Count == 0)
|
if (datItems.Count == 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
foreach (DatItem datItem in datItems)
|
foreach (DatItem datItem in datItems)
|
||||||
|
|||||||
Reference in New Issue
Block a user