Move contents test in optical media image test to its own separate test.

This commit is contained in:
2021-07-09 09:50:41 +01:00
parent da157fe16f
commit 4c44c19d1d

View File

@@ -107,6 +107,41 @@ namespace Aaru.Tests.Images
$"Last sector for tracks is {latestEndSector}, but it is {image.Info.Sectors} for image"); $"Last sector for tracks is {latestEndSector}, but it is {image.Info.Sectors} for image");
}); });
} }
}
});
}
[Test]
public void Contents()
{
Environment.CurrentDirectory = DataFolder;
Assert.Multiple(() =>
{
foreach(OpticalImageTestExpected test in Tests)
{
string testFile = test.TestFile;
bool exists = File.Exists(testFile);
Assert.True(exists, $"{testFile} not found");
// ReSharper disable once ConditionIsAlwaysTrueOrFalse
// It arrives here...
if(!exists)
continue;
var filtersList = new FiltersList();
IFilter filter = filtersList.GetFilter(testFile);
filter.Open(testFile);
var image = Activator.CreateInstance(_plugin.GetType()) as IOpticalMediaImage;
Assert.NotNull(image, $"Could not instantiate filesystem for {testFile}");
bool opened = image.Open(filter);
Assert.AreEqual(true, opened, $"Open: {testFile}");
if(!opened)
continue;
using(new AssertionScope()) using(new AssertionScope())
{ {
@@ -232,13 +267,12 @@ namespace Aaru.Tests.Images
ReadOnlyFilesystemTest.TestDirectory(rofs, "/", track.FileSystems[i].Contents, ReadOnlyFilesystemTest.TestDirectory(rofs, "/", track.FileSystems[i].Contents,
testFile, false); testFile, false);
/* Uncomment to generate JSON file // Uncomment to generate JSON file
var contents = ReadOnlyFilesystemTest.BuildDirectory(rofs, "/"); /* var contents = ReadOnlyFilesystemTest.BuildDirectory(rofs, "/");
var sw = new StreamWriter($"{testFile}.track{track.Number}.filesystem{i}.contents.json"); var sw = new StreamWriter($"{testFile}.track{track.Number}.filesystem{i}.contents.json");
serializer.Serialize(sw, contents); serializer.Serialize(sw, contents);
sw.Close(); sw.Close();*/
*/
} }
} }
}); });