[Aaru.Tests] Reformat and cleanup.

This commit is contained in:
2023-10-03 23:44:33 +01:00
parent 4b7fe8a837
commit 1f36ef2424
171 changed files with 1608 additions and 1661 deletions

View File

@@ -16,21 +16,21 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Claunia.Encoding" Version="1.9.2" /> <PackageReference Include="Claunia.Encoding" Version="1.9.2"/>
<PackageReference Include="FluentAssertions" Version="6.12.0" /> <PackageReference Include="FluentAssertions" Version="6.12.0"/>
<PackageReference Include="nunit" Version="3.13.3" /> <PackageReference Include="nunit" Version="3.13.3"/>
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" /> <PackageReference Include="NUnit3TestAdapter" Version="4.5.0"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2"/>
<PackageReference Include="System.Text.Encoding.CodePages" Version="8.0.0-rc.1.23419.4" /> <PackageReference Include="System.Text.Encoding.CodePages" Version="8.0.0-rc.1.23419.4"/>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Aaru.Checksums\Aaru.Checksums.csproj" /> <ProjectReference Include="..\Aaru.Checksums\Aaru.Checksums.csproj"/>
<ProjectReference Include="..\Aaru.CommonTypes\Aaru.CommonTypes.csproj" /> <ProjectReference Include="..\Aaru.CommonTypes\Aaru.CommonTypes.csproj"/>
<ProjectReference Include="..\Aaru.Core\Aaru.Core.csproj" /> <ProjectReference Include="..\Aaru.Core\Aaru.Core.csproj"/>
<ProjectReference Include="..\Aaru.Filesystems\Aaru.Filesystems.csproj" /> <ProjectReference Include="..\Aaru.Filesystems\Aaru.Filesystems.csproj"/>
<ProjectReference Include="..\Aaru.Filters\Aaru.Filters.csproj" /> <ProjectReference Include="..\Aaru.Filters\Aaru.Filters.csproj"/>
<ProjectReference Include="..\Aaru.Images\Aaru.Images.csproj" /> <ProjectReference Include="..\Aaru.Images\Aaru.Images.csproj"/>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -1,5 +1,6 @@
<wpf:ResourceDictionary xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" <wpf:ResourceDictionary xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:s="clr-namespace:System;assembly=mscorlib"
xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xml:space="preserve"> xml:space="preserve">
<s:Boolean <s:Boolean
x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=localization/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=localization/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

View File

@@ -38,40 +38,25 @@ namespace Aaru.Tests.Checksums;
[TestFixture] [TestFixture]
public class Adler32 public class Adler32
{ {
static readonly byte[] _expectedEmpty = static readonly byte[] _expectedEmpty = { 0x00, 0xf0, 0x00, 0x01 };
{
0x00, 0xf0, 0x00, 0x01
};
static readonly byte[] _expectedRandom = static readonly byte[] _expectedRandom =
{ {
// ReSharper disable once UseUtf8StringLiteral // ReSharper disable once UseUtf8StringLiteral
0x37, 0x28, 0xd1, 0x86 0x37, 0x28, 0xd1, 0x86
}; };
static readonly byte[] _expectedRandom15 = static readonly byte[] _expectedRandom15 = { 0x34, 0xDC, 0x06, 0x7D };
{
0x34, 0xDC, 0x06, 0x7D
};
static readonly byte[] _expectedRandom31 = static readonly byte[] _expectedRandom31 = { 0xD8, 0xF1, 0x0E, 0xAA };
{
0xD8, 0xF1, 0x0E, 0xAA
};
static readonly byte[] _expectedRandom63 = static readonly byte[] _expectedRandom63 = { 0xD8, 0xAC, 0x20, 0x81 };
{
0xD8, 0xAC, 0x20, 0x81
};
static readonly byte[] _expectedRandom2352 = static readonly byte[] _expectedRandom2352 = { 0xEC, 0xD1, 0x73, 0x8B };
{
0xEC, 0xD1, 0x73, 0x8B
};
[Test] [Test]
public void EmptyData() public void EmptyData()
{ {
byte[] data = new byte[1048576]; var data = new byte[1048576];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open, var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open,
FileAccess.Read); FileAccess.Read);
@@ -93,7 +78,7 @@ public class Adler32
[Test] [Test]
public void EmptyInstance() public void EmptyInstance()
{ {
byte[] data = new byte[1048576]; var data = new byte[1048576];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open, var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open,
FileAccess.Read); FileAccess.Read);
@@ -107,10 +92,78 @@ public class Adler32
result.Should().BeEquivalentTo(_expectedEmpty); result.Should().BeEquivalentTo(_expectedEmpty);
} }
[Test]
public void PartialInstanceAuto15()
{
var data = new byte[15];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read);
fs.EnsureRead(data, 0, 15);
fs.Close();
fs.Dispose();
IChecksum ctx = new Adler32Context();
ctx.Update(data);
byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom15);
}
[Test]
public void PartialInstanceAuto2352()
{
var data = new byte[2352];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read);
fs.EnsureRead(data, 0, 2352);
fs.Close();
fs.Dispose();
IChecksum ctx = new Adler32Context();
ctx.Update(data);
byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom2352);
}
[Test]
public void PartialInstanceAuto31()
{
var data = new byte[31];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read);
fs.EnsureRead(data, 0, 31);
fs.Close();
fs.Dispose();
IChecksum ctx = new Adler32Context();
ctx.Update(data);
byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom31);
}
[Test]
public void PartialInstanceAuto63()
{
var data = new byte[63];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read);
fs.EnsureRead(data, 0, 63);
fs.Close();
fs.Dispose();
IChecksum ctx = new Adler32Context();
ctx.Update(data);
byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom63);
}
[Test] [Test]
public void RandomData() public void RandomData()
{ {
byte[] data = new byte[1048576]; var data = new byte[1048576];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open, var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read); FileAccess.Read);
@@ -132,7 +185,7 @@ public class Adler32
[Test] [Test]
public void RandomInstance() public void RandomInstance()
{ {
byte[] data = new byte[1048576]; var data = new byte[1048576];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open, var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read); FileAccess.Read);
@@ -145,72 +198,4 @@ public class Adler32
byte[] result = ctx.Final(); byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom); result.Should().BeEquivalentTo(_expectedRandom);
} }
[Test]
public void PartialInstanceAuto15()
{
byte[] data = new byte[15];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read);
fs.EnsureRead(data, 0, 15);
fs.Close();
fs.Dispose();
IChecksum ctx = new Adler32Context();
ctx.Update(data);
byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom15);
}
[Test]
public void PartialInstanceAuto31()
{
byte[] data = new byte[31];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read);
fs.EnsureRead(data, 0, 31);
fs.Close();
fs.Dispose();
IChecksum ctx = new Adler32Context();
ctx.Update(data);
byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom31);
}
[Test]
public void PartialInstanceAuto63()
{
byte[] data = new byte[63];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read);
fs.EnsureRead(data, 0, 63);
fs.Close();
fs.Dispose();
IChecksum ctx = new Adler32Context();
ctx.Update(data);
byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom63);
}
[Test]
public void PartialInstanceAuto2352()
{
byte[] data = new byte[2352];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read);
fs.EnsureRead(data, 0, 2352);
fs.Close();
fs.Dispose();
IChecksum ctx = new Adler32Context();
ctx.Update(data);
byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom2352);
}
} }

View File

@@ -37,36 +37,21 @@ namespace Aaru.Tests.Checksums;
[TestFixture] [TestFixture]
public class Crc16Ccitt public class Crc16Ccitt
{ {
static readonly byte[] _expectedEmpty = static readonly byte[] _expectedEmpty = { 0xFF, 0xFF };
{
0xFF, 0xFF
};
static readonly byte[] _expectedRandom = static readonly byte[] _expectedRandom =
{ {
// ReSharper disable once UseUtf8StringLiteral // ReSharper disable once UseUtf8StringLiteral
0x36, 0x40 0x36, 0x40
}; };
static readonly byte[] _expectedRandom15 = static readonly byte[] _expectedRandom15 = { 0x16, 0x6e };
{ static readonly byte[] _expectedRandom31 = { 0xd0, 0x16 };
0x16, 0x6e static readonly byte[] _expectedRandom63 = { 0x73, 0xc4 };
}; static readonly byte[] _expectedRandom2352 = { 0x19, 0x46 };
static readonly byte[] _expectedRandom31 =
{
0xd0, 0x16
};
static readonly byte[] _expectedRandom63 =
{
0x73, 0xc4
};
static readonly byte[] _expectedRandom2352 =
{
0x19, 0x46
};
[Test] [Test]
public void EmptyData() public void EmptyData()
{ {
byte[] data = new byte[1048576]; var data = new byte[1048576];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open, var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open,
FileAccess.Read); FileAccess.Read);
@@ -89,7 +74,7 @@ public class Crc16Ccitt
[Test] [Test]
public void EmptyInstance() public void EmptyInstance()
{ {
byte[] data = new byte[1048576]; var data = new byte[1048576];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open, var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open,
FileAccess.Read); FileAccess.Read);
@@ -103,10 +88,78 @@ public class Crc16Ccitt
result.Should().BeEquivalentTo(_expectedEmpty); result.Should().BeEquivalentTo(_expectedEmpty);
} }
[Test]
public void PartialInstance15()
{
var data = new byte[15];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read);
fs.EnsureRead(data, 0, 15);
fs.Close();
fs.Dispose();
var ctx = new CRC16CCITTContext();
ctx.Update(data);
byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom15);
}
[Test]
public void PartialInstance2352()
{
var data = new byte[2352];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read);
fs.EnsureRead(data, 0, 2352);
fs.Close();
fs.Dispose();
var ctx = new CRC16CCITTContext();
ctx.Update(data);
byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom2352);
}
[Test]
public void PartialInstance31()
{
var data = new byte[31];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read);
fs.EnsureRead(data, 0, 31);
fs.Close();
fs.Dispose();
var ctx = new CRC16CCITTContext();
ctx.Update(data);
byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom31);
}
[Test]
public void PartialInstance63()
{
var data = new byte[63];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read);
fs.EnsureRead(data, 0, 63);
fs.Close();
fs.Dispose();
var ctx = new CRC16CCITTContext();
ctx.Update(data);
byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom63);
}
[Test] [Test]
public void RandomData() public void RandomData()
{ {
byte[] data = new byte[1048576]; var data = new byte[1048576];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open, var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read); FileAccess.Read);
@@ -129,7 +182,7 @@ public class Crc16Ccitt
[Test] [Test]
public void RandomInstance() public void RandomInstance()
{ {
byte[] data = new byte[1048576]; var data = new byte[1048576];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open, var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read); FileAccess.Read);
@@ -142,72 +195,4 @@ public class Crc16Ccitt
byte[] result = ctx.Final(); byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom); result.Should().BeEquivalentTo(_expectedRandom);
} }
[Test]
public void PartialInstance15()
{
byte[] data = new byte[15];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read);
fs.EnsureRead(data, 0, 15);
fs.Close();
fs.Dispose();
var ctx = new CRC16CCITTContext();
ctx.Update(data);
byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom15);
}
[Test]
public void PartialInstance31()
{
byte[] data = new byte[31];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read);
fs.EnsureRead(data, 0, 31);
fs.Close();
fs.Dispose();
var ctx = new CRC16CCITTContext();
ctx.Update(data);
byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom31);
}
[Test]
public void PartialInstance63()
{
byte[] data = new byte[63];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read);
fs.EnsureRead(data, 0, 63);
fs.Close();
fs.Dispose();
var ctx = new CRC16CCITTContext();
ctx.Update(data);
byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom63);
}
[Test]
public void PartialInstance2352()
{
byte[] data = new byte[2352];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read);
fs.EnsureRead(data, 0, 2352);
fs.Close();
fs.Dispose();
var ctx = new CRC16CCITTContext();
ctx.Update(data);
byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom2352);
}
} }

View File

@@ -38,36 +38,21 @@ namespace Aaru.Tests.Checksums;
[TestFixture] [TestFixture]
public class Crc16Ibm public class Crc16Ibm
{ {
static readonly byte[] _expectedEmpty = static readonly byte[] _expectedEmpty = { 0x00, 0x00 };
{
0x00, 0x00
};
static readonly byte[] _expectedRandom = static readonly byte[] _expectedRandom =
{ {
// ReSharper disable once UseUtf8StringLiteral // ReSharper disable once UseUtf8StringLiteral
0x2d, 0x6d 0x2d, 0x6d
}; };
static readonly byte[] _expectedRandom15 = static readonly byte[] _expectedRandom15 = { 0x72, 0xa6 };
{ static readonly byte[] _expectedRandom31 = { 0xf4, 0x9e };
0x72, 0xa6 static readonly byte[] _expectedRandom63 = { 0xfb, 0xd9 };
}; static readonly byte[] _expectedRandom2352 = { 0x23, 0xf4 };
static readonly byte[] _expectedRandom31 =
{
0xf4, 0x9e
};
static readonly byte[] _expectedRandom63 =
{
0xfb, 0xd9
};
static readonly byte[] _expectedRandom2352 =
{
0x23, 0xf4
};
[Test] [Test]
public void EmptyData() public void EmptyData()
{ {
byte[] data = new byte[1048576]; var data = new byte[1048576];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open, var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open,
FileAccess.Read); FileAccess.Read);
@@ -90,7 +75,7 @@ public class Crc16Ibm
[Test] [Test]
public void EmptyInstance() public void EmptyInstance()
{ {
byte[] data = new byte[1048576]; var data = new byte[1048576];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open, var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open,
FileAccess.Read); FileAccess.Read);
@@ -104,10 +89,78 @@ public class Crc16Ibm
result.Should().BeEquivalentTo(_expectedEmpty); result.Should().BeEquivalentTo(_expectedEmpty);
} }
[Test]
public void PartialInstance15()
{
var data = new byte[15];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read);
fs.EnsureRead(data, 0, 15);
fs.Close();
fs.Dispose();
IChecksum ctx = new CRC16IBMContext();
ctx.Update(data);
byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom15);
}
[Test]
public void PartialInstance2352()
{
var data = new byte[2352];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read);
fs.EnsureRead(data, 0, 2352);
fs.Close();
fs.Dispose();
IChecksum ctx = new CRC16IBMContext();
ctx.Update(data);
byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom2352);
}
[Test]
public void PartialInstance31()
{
var data = new byte[31];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read);
fs.EnsureRead(data, 0, 31);
fs.Close();
fs.Dispose();
IChecksum ctx = new CRC16IBMContext();
ctx.Update(data);
byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom31);
}
[Test]
public void PartialInstance63()
{
var data = new byte[63];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read);
fs.EnsureRead(data, 0, 63);
fs.Close();
fs.Dispose();
IChecksum ctx = new CRC16IBMContext();
ctx.Update(data);
byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom63);
}
[Test] [Test]
public void RandomData() public void RandomData()
{ {
byte[] data = new byte[1048576]; var data = new byte[1048576];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open, var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read); FileAccess.Read);
@@ -130,7 +183,7 @@ public class Crc16Ibm
[Test] [Test]
public void RandomInstance() public void RandomInstance()
{ {
byte[] data = new byte[1048576]; var data = new byte[1048576];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open, var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read); FileAccess.Read);
@@ -143,72 +196,4 @@ public class Crc16Ibm
byte[] result = ctx.Final(); byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom); result.Should().BeEquivalentTo(_expectedRandom);
} }
[Test]
public void PartialInstance15()
{
byte[] data = new byte[15];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read);
fs.EnsureRead(data, 0, 15);
fs.Close();
fs.Dispose();
IChecksum ctx = new CRC16IBMContext();
ctx.Update(data);
byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom15);
}
[Test]
public void PartialInstance31()
{
byte[] data = new byte[31];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read);
fs.EnsureRead(data, 0, 31);
fs.Close();
fs.Dispose();
IChecksum ctx = new CRC16IBMContext();
ctx.Update(data);
byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom31);
}
[Test]
public void PartialInstance63()
{
byte[] data = new byte[63];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read);
fs.EnsureRead(data, 0, 63);
fs.Close();
fs.Dispose();
IChecksum ctx = new CRC16IBMContext();
ctx.Update(data);
byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom63);
}
[Test]
public void PartialInstance2352()
{
byte[] data = new byte[2352];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read);
fs.EnsureRead(data, 0, 2352);
fs.Close();
fs.Dispose();
IChecksum ctx = new CRC16IBMContext();
ctx.Update(data);
byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom2352);
}
} }

View File

@@ -38,36 +38,21 @@ namespace Aaru.Tests.Checksums;
[TestFixture] [TestFixture]
public class Crc32 public class Crc32
{ {
static readonly byte[] _expectedEmpty = static readonly byte[] _expectedEmpty = { 0xa7, 0x38, 0xea, 0x1c };
{
0xa7, 0x38, 0xea, 0x1c
};
static readonly byte[] _expectedRandom = static readonly byte[] _expectedRandom =
{ {
// ReSharper disable once UseUtf8StringLiteral // ReSharper disable once UseUtf8StringLiteral
0x2b, 0x6e, 0x68, 0x54 0x2b, 0x6e, 0x68, 0x54
}; };
static readonly byte[] _expectedRandom15 = static readonly byte[] _expectedRandom15 = { 0xad, 0x6d, 0xa7, 0x27 };
{ static readonly byte[] _expectedRandom31 = { 0xa2, 0xad, 0x2f, 0xaa };
0xad, 0x6d, 0xa7, 0x27 static readonly byte[] _expectedRandom63 = { 0xbf, 0xf6, 0xa3, 0x41 };
}; static readonly byte[] _expectedRandom2352 = { 0x08, 0xba, 0x93, 0xea };
static readonly byte[] _expectedRandom31 =
{
0xa2, 0xad, 0x2f, 0xaa
};
static readonly byte[] _expectedRandom63 =
{
0xbf, 0xf6, 0xa3, 0x41
};
static readonly byte[] _expectedRandom2352 =
{
0x08, 0xba, 0x93, 0xea
};
[Test] [Test]
public void EmptyData() public void EmptyData()
{ {
byte[] data = new byte[1048576]; var data = new byte[1048576];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open, var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open,
FileAccess.Read); FileAccess.Read);
@@ -89,7 +74,7 @@ public class Crc32
[Test] [Test]
public void EmptyInstance() public void EmptyInstance()
{ {
byte[] data = new byte[1048576]; var data = new byte[1048576];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open, var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open,
FileAccess.Read); FileAccess.Read);
@@ -103,10 +88,78 @@ public class Crc32
result.Should().BeEquivalentTo(_expectedEmpty); result.Should().BeEquivalentTo(_expectedEmpty);
} }
[Test]
public void PartialInstance15()
{
var data = new byte[15];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read);
fs.EnsureRead(data, 0, 15);
fs.Close();
fs.Dispose();
IChecksum ctx = new Crc32Context();
ctx.Update(data);
byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom15);
}
[Test]
public void PartialInstance2352()
{
var data = new byte[2352];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read);
fs.EnsureRead(data, 0, 2352);
fs.Close();
fs.Dispose();
IChecksum ctx = new Crc32Context();
ctx.Update(data);
byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom2352);
}
[Test]
public void PartialInstance31()
{
var data = new byte[31];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read);
fs.EnsureRead(data, 0, 31);
fs.Close();
fs.Dispose();
IChecksum ctx = new Crc32Context();
ctx.Update(data);
byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom31);
}
[Test]
public void PartialInstance63()
{
var data = new byte[63];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read);
fs.EnsureRead(data, 0, 63);
fs.Close();
fs.Dispose();
IChecksum ctx = new Crc32Context();
ctx.Update(data);
byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom63);
}
[Test] [Test]
public void RandomData() public void RandomData()
{ {
byte[] data = new byte[1048576]; var data = new byte[1048576];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open, var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read); FileAccess.Read);
@@ -128,7 +181,7 @@ public class Crc32
[Test] [Test]
public void RandomInstance() public void RandomInstance()
{ {
byte[] data = new byte[1048576]; var data = new byte[1048576];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open, var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read); FileAccess.Read);
@@ -141,72 +194,4 @@ public class Crc32
byte[] result = ctx.Final(); byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom); result.Should().BeEquivalentTo(_expectedRandom);
} }
[Test]
public void PartialInstance15()
{
byte[] data = new byte[15];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read);
fs.EnsureRead(data, 0, 15);
fs.Close();
fs.Dispose();
IChecksum ctx = new Crc32Context();
ctx.Update(data);
byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom15);
}
[Test]
public void PartialInstance31()
{
byte[] data = new byte[31];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read);
fs.EnsureRead(data, 0, 31);
fs.Close();
fs.Dispose();
IChecksum ctx = new Crc32Context();
ctx.Update(data);
byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom31);
}
[Test]
public void PartialInstance63()
{
byte[] data = new byte[63];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read);
fs.EnsureRead(data, 0, 63);
fs.Close();
fs.Dispose();
IChecksum ctx = new Crc32Context();
ctx.Update(data);
byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom63);
}
[Test]
public void PartialInstance2352()
{
byte[] data = new byte[2352];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read);
fs.EnsureRead(data, 0, 2352);
fs.Close();
fs.Dispose();
IChecksum ctx = new Crc32Context();
ctx.Update(data);
byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom2352);
}
} }

View File

@@ -38,35 +38,17 @@ namespace Aaru.Tests.Checksums;
[TestFixture] [TestFixture]
public class Crc64 public class Crc64
{ {
static readonly byte[] _expectedEmpty = static readonly byte[] _expectedEmpty = { 0x60, 0x6b, 0x70, 0xa2, 0x3e, 0xba, 0xf6, 0xc2 };
{ static readonly byte[] _expectedRandom = { 0xbf, 0x09, 0x99, 0x2c, 0xc5, 0xed, 0xe3, 0x8e };
0x60, 0x6b, 0x70, 0xa2, 0x3e, 0xba, 0xf6, 0xc2 static readonly byte[] _expectedRandom15 = { 0x79, 0x7F, 0x37, 0x66, 0xFD, 0x93, 0x97, 0x5B };
}; static readonly byte[] _expectedRandom31 = { 0xCD, 0x92, 0x01, 0x90, 0x5A, 0x79, 0x37, 0xFD };
static readonly byte[] _expectedRandom = static readonly byte[] _expectedRandom63 = { 0x29, 0xF3, 0x31, 0xFC, 0x90, 0x70, 0x2B, 0xF4 };
{ static readonly byte[] _expectedRandom2352 = { 0x12, 0x64, 0x35, 0xDB, 0x43, 0x47, 0x76, 0x23 };
0xbf, 0x09, 0x99, 0x2c, 0xc5, 0xed, 0xe3, 0x8e
};
static readonly byte[] _expectedRandom15 =
{
0x79, 0x7F, 0x37, 0x66, 0xFD, 0x93, 0x97, 0x5B
};
static readonly byte[] _expectedRandom31 =
{
0xCD, 0x92, 0x01, 0x90, 0x5A, 0x79, 0x37, 0xFD
};
static readonly byte[] _expectedRandom63 =
{
0x29, 0xF3, 0x31, 0xFC, 0x90, 0x70, 0x2B, 0xF4
};
static readonly byte[] _expectedRandom2352 =
{
0x12, 0x64, 0x35, 0xDB, 0x43, 0x47, 0x76, 0x23
};
[Test] [Test]
public void EmptyData() public void EmptyData()
{ {
byte[] data = new byte[1048576]; var data = new byte[1048576];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open, var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open,
FileAccess.Read); FileAccess.Read);
@@ -88,7 +70,7 @@ public class Crc64
[Test] [Test]
public void EmptyInstance() public void EmptyInstance()
{ {
byte[] data = new byte[1048576]; var data = new byte[1048576];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open, var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open,
FileAccess.Read); FileAccess.Read);
@@ -102,10 +84,78 @@ public class Crc64
result.Should().BeEquivalentTo(_expectedEmpty); result.Should().BeEquivalentTo(_expectedEmpty);
} }
[Test]
public void PartialInstance15()
{
var data = new byte[15];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read);
fs.EnsureRead(data, 0, 15);
fs.Close();
fs.Dispose();
IChecksum ctx = new Crc64Context();
ctx.Update(data);
byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom15);
}
[Test]
public void PartialInstance2352()
{
var data = new byte[2352];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read);
fs.EnsureRead(data, 0, 2352);
fs.Close();
fs.Dispose();
IChecksum ctx = new Crc64Context();
ctx.Update(data);
byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom2352);
}
[Test]
public void PartialInstance31()
{
var data = new byte[31];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read);
fs.EnsureRead(data, 0, 31);
fs.Close();
fs.Dispose();
IChecksum ctx = new Crc64Context();
ctx.Update(data);
byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom31);
}
[Test]
public void PartialInstance63()
{
var data = new byte[63];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read);
fs.EnsureRead(data, 0, 63);
fs.Close();
fs.Dispose();
IChecksum ctx = new Crc64Context();
ctx.Update(data);
byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom63);
}
[Test] [Test]
public void RandomData() public void RandomData()
{ {
byte[] data = new byte[1048576]; var data = new byte[1048576];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open, var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read); FileAccess.Read);
@@ -127,7 +177,7 @@ public class Crc64
[Test] [Test]
public void RandomInstance() public void RandomInstance()
{ {
byte[] data = new byte[1048576]; var data = new byte[1048576];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open, var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read); FileAccess.Read);
@@ -140,72 +190,4 @@ public class Crc64
byte[] result = ctx.Final(); byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom); result.Should().BeEquivalentTo(_expectedRandom);
} }
[Test]
public void PartialInstance15()
{
byte[] data = new byte[15];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read);
fs.EnsureRead(data, 0, 15);
fs.Close();
fs.Dispose();
IChecksum ctx = new Crc64Context();
ctx.Update(data);
byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom15);
}
[Test]
public void PartialInstance31()
{
byte[] data = new byte[31];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read);
fs.EnsureRead(data, 0, 31);
fs.Close();
fs.Dispose();
IChecksum ctx = new Crc64Context();
ctx.Update(data);
byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom31);
}
[Test]
public void PartialInstance63()
{
byte[] data = new byte[63];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read);
fs.EnsureRead(data, 0, 63);
fs.Close();
fs.Dispose();
IChecksum ctx = new Crc64Context();
ctx.Update(data);
byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom63);
}
[Test]
public void PartialInstance2352()
{
byte[] data = new byte[2352];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read);
fs.EnsureRead(data, 0, 2352);
fs.Close();
fs.Dispose();
IChecksum ctx = new Crc64Context();
ctx.Update(data);
byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom2352);
}
} }

View File

@@ -50,7 +50,7 @@ public class Md5
[Test] [Test]
public void EmptyData() public void EmptyData()
{ {
byte[] data = new byte[1048576]; var data = new byte[1048576];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open, var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open,
FileAccess.Read); FileAccess.Read);
@@ -72,7 +72,7 @@ public class Md5
[Test] [Test]
public void EmptyInstance() public void EmptyInstance()
{ {
byte[] data = new byte[1048576]; var data = new byte[1048576];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open, var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open,
FileAccess.Read); FileAccess.Read);
@@ -89,7 +89,7 @@ public class Md5
[Test] [Test]
public void RandomData() public void RandomData()
{ {
byte[] data = new byte[1048576]; var data = new byte[1048576];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open, var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read); FileAccess.Read);
@@ -111,7 +111,7 @@ public class Md5
[Test] [Test]
public void RandomInstance() public void RandomInstance()
{ {
byte[] data = new byte[1048576]; var data = new byte[1048576];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open, var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read); FileAccess.Read);

View File

@@ -52,7 +52,7 @@ public class Sha1
[Test] [Test]
public void EmptyData() public void EmptyData()
{ {
byte[] data = new byte[1048576]; var data = new byte[1048576];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open, var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open,
FileAccess.Read); FileAccess.Read);
@@ -74,7 +74,7 @@ public class Sha1
[Test] [Test]
public void EmptyInstance() public void EmptyInstance()
{ {
byte[] data = new byte[1048576]; var data = new byte[1048576];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open, var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open,
FileAccess.Read); FileAccess.Read);
@@ -91,7 +91,7 @@ public class Sha1
[Test] [Test]
public void RandomData() public void RandomData()
{ {
byte[] data = new byte[1048576]; var data = new byte[1048576];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open, var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read); FileAccess.Read);
@@ -113,7 +113,7 @@ public class Sha1
[Test] [Test]
public void RandomInstance() public void RandomInstance()
{ {
byte[] data = new byte[1048576]; var data = new byte[1048576];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open, var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read); FileAccess.Read);

View File

@@ -52,7 +52,7 @@ public class Sha256
[Test] [Test]
public void EmptyData() public void EmptyData()
{ {
byte[] data = new byte[1048576]; var data = new byte[1048576];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open, var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open,
FileAccess.Read); FileAccess.Read);
@@ -74,7 +74,7 @@ public class Sha256
[Test] [Test]
public void EmptyInstance() public void EmptyInstance()
{ {
byte[] data = new byte[1048576]; var data = new byte[1048576];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open, var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open,
FileAccess.Read); FileAccess.Read);
@@ -91,7 +91,7 @@ public class Sha256
[Test] [Test]
public void RandomData() public void RandomData()
{ {
byte[] data = new byte[1048576]; var data = new byte[1048576];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open, var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read); FileAccess.Read);
@@ -113,7 +113,7 @@ public class Sha256
[Test] [Test]
public void RandomInstance() public void RandomInstance()
{ {
byte[] data = new byte[1048576]; var data = new byte[1048576];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open, var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read); FileAccess.Read);

View File

@@ -54,7 +54,7 @@ public class Sha384
[Test] [Test]
public void EmptyData() public void EmptyData()
{ {
byte[] data = new byte[1048576]; var data = new byte[1048576];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open, var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open,
FileAccess.Read); FileAccess.Read);
@@ -76,7 +76,7 @@ public class Sha384
[Test] [Test]
public void EmptyInstance() public void EmptyInstance()
{ {
byte[] data = new byte[1048576]; var data = new byte[1048576];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open, var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open,
FileAccess.Read); FileAccess.Read);
@@ -93,7 +93,7 @@ public class Sha384
[Test] [Test]
public void RandomData() public void RandomData()
{ {
byte[] data = new byte[1048576]; var data = new byte[1048576];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open, var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read); FileAccess.Read);
@@ -115,7 +115,7 @@ public class Sha384
[Test] [Test]
public void RandomInstance() public void RandomInstance()
{ {
byte[] data = new byte[1048576]; var data = new byte[1048576];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open, var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read); FileAccess.Read);

View File

@@ -56,7 +56,7 @@ public class Sha512
[Test] [Test]
public void EmptyData() public void EmptyData()
{ {
byte[] data = new byte[1048576]; var data = new byte[1048576];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open, var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open,
FileAccess.Read); FileAccess.Read);
@@ -78,7 +78,7 @@ public class Sha512
[Test] [Test]
public void EmptyInstance() public void EmptyInstance()
{ {
byte[] data = new byte[1048576]; var data = new byte[1048576];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open, var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open,
FileAccess.Read); FileAccess.Read);
@@ -95,7 +95,7 @@ public class Sha512
[Test] [Test]
public void RandomData() public void RandomData()
{ {
byte[] data = new byte[1048576]; var data = new byte[1048576];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open, var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read); FileAccess.Read);
@@ -117,7 +117,7 @@ public class Sha512
[Test] [Test]
public void RandomInstance() public void RandomInstance()
{ {
byte[] data = new byte[1048576]; var data = new byte[1048576];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open, var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read); FileAccess.Read);

View File

@@ -43,7 +43,7 @@ public class SpamSum
[Test] [Test]
public void EmptyData() public void EmptyData()
{ {
byte[] data = new byte[1048576]; var data = new byte[1048576];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open, var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open,
FileAccess.Read); FileAccess.Read);
@@ -58,7 +58,7 @@ public class SpamSum
[Test] [Test]
public void EmptyInstance() public void EmptyInstance()
{ {
byte[] data = new byte[1048576]; var data = new byte[1048576];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open, var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open,
FileAccess.Read); FileAccess.Read);
@@ -75,7 +75,7 @@ public class SpamSum
[Test] [Test]
public void RandomData() public void RandomData()
{ {
byte[] data = new byte[1048576]; var data = new byte[1048576];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open, var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read); FileAccess.Read);
@@ -90,7 +90,7 @@ public class SpamSum
[Test] [Test]
public void RandomInstance() public void RandomInstance()
{ {
byte[] data = new byte[1048576]; var data = new byte[1048576];
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open, var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read); FileAccess.Read);

View File

@@ -40,25 +40,13 @@ namespace Aaru.Tests.Devices;
[TestFixture] [TestFixture]
public class IomegaJaz public class IomegaJaz
{ {
readonly string[] _testFiles = readonly string[] _testFiles = { "jaz1.bin.lz" };
{
"jaz1.bin.lz"
};
readonly MediaType[] _mediaTypes = readonly MediaType[] _mediaTypes = { MediaType.Jaz };
{
MediaType.Jaz
};
readonly ulong[] _sectors = readonly ulong[] _sectors = { 2091050 };
{
2091050
};
readonly uint[] _sectorSize = readonly uint[] _sectorSize = { 512 };
{
512
};
readonly string _dataFolder = Path.Combine(Consts.TestFilesRoot, "Device test dumps", "JAZ"); readonly string _dataFolder = Path.Combine(Consts.TestFilesRoot, "Device test dumps", "JAZ");
@@ -69,7 +57,7 @@ public class IomegaJaz
Assert.Multiple(() => Assert.Multiple(() =>
{ {
for(int i = 0; i < _testFiles.Length; i++) for(var i = 0; i < _testFiles.Length; i++)
{ {
var filter = new LZip(); var filter = new LZip();
filter.Open(_testFiles[i]); filter.Open(_testFiles[i]);
@@ -83,6 +71,7 @@ public class IomegaJaz
continue; continue;
using(new AssertionScope()) using(new AssertionScope())
{
Assert.Multiple(() => Assert.Multiple(() =>
{ {
Assert.AreEqual(_sectors[i], image.Info.Sectors, Assert.AreEqual(_sectors[i], image.Info.Sectors,
@@ -94,6 +83,7 @@ public class IomegaJaz
Assert.AreEqual(_mediaTypes[i], image.Info.MediaType, Assert.AreEqual(_mediaTypes[i], image.Info.MediaType,
string.Format(Localization.Media_type_0, _testFiles[i])); string.Format(Localization.Media_type_0, _testFiles[i]));
}); });
}
} }
}); });
} }

View File

@@ -40,25 +40,13 @@ namespace Aaru.Tests.Devices;
[TestFixture] [TestFixture]
public class Ls120 public class Ls120
{ {
readonly string[] _testFiles = readonly string[] _testFiles = { "ls120.bin.lz", "mf2dd.bin.lz", "mf2hd.bin.lz" };
{
"ls120.bin.lz", "mf2dd.bin.lz", "mf2hd.bin.lz"
};
readonly MediaType[] _mediaTypes = readonly MediaType[] _mediaTypes = { MediaType.LS120, MediaType.DOS_35_DS_DD_9, MediaType.DOS_35_HD };
{
MediaType.LS120, MediaType.DOS_35_DS_DD_9, MediaType.DOS_35_HD
};
readonly ulong[] _sectors = readonly ulong[] _sectors = { 246528, 1440, 2880 };
{
246528, 1440, 2880
};
readonly uint[] _sectorSize = readonly uint[] _sectorSize = { 512, 512, 512 };
{
512, 512, 512
};
readonly string _dataFolder = Path.Combine(Consts.TestFilesRoot, "Device test dumps", "LS-120"); readonly string _dataFolder = Path.Combine(Consts.TestFilesRoot, "Device test dumps", "LS-120");
@@ -69,7 +57,7 @@ public class Ls120
Assert.Multiple(() => Assert.Multiple(() =>
{ {
for(int i = 0; i < _testFiles.Length; i++) for(var i = 0; i < _testFiles.Length; i++)
{ {
var filter = new LZip(); var filter = new LZip();
filter.Open(_testFiles[i]); filter.Open(_testFiles[i]);
@@ -83,6 +71,7 @@ public class Ls120
continue; continue;
using(new AssertionScope()) using(new AssertionScope())
{
Assert.Multiple(() => Assert.Multiple(() =>
{ {
Assert.AreEqual(_sectors[i], image.Info.Sectors, Assert.AreEqual(_sectors[i], image.Info.Sectors,
@@ -94,6 +83,7 @@ public class Ls120
Assert.AreEqual(_mediaTypes[i], image.Info.MediaType, Assert.AreEqual(_mediaTypes[i], image.Info.MediaType,
string.Format(Localization.Media_type_0, _testFiles[i])); string.Format(Localization.Media_type_0, _testFiles[i]));
}); });
}
} }
}); });
} }

View File

@@ -9,56 +9,34 @@ namespace Aaru.Tests.Devices.MultiMediaCard;
[TestFixture] [TestFixture]
public class CID public class CID
{ {
readonly string[] cards = readonly string[] cards = { "mmc_6600_32mb", "mmc_pretec_32mb", "mmc_takems_256mb" };
{
"mmc_6600_32mb", "mmc_pretec_32mb", "mmc_takems_256mb"
};
readonly string[] cids = readonly string[] cids =
{ {
"15000030303030303007b20212909701", "06000033324d202020011923a457c601", "2c0000414620484d5010a9000b1a6801" "15000030303030303007b20212909701", "06000033324d202020011923a457c601", "2c0000414620484d5010a9000b1a6801"
}; };
readonly byte[] manufacturers = readonly byte[] manufacturers = { 0x15, 0x06, 0x2c };
{
0x15, 0x06, 0x2c
};
readonly ushort[] applications = readonly ushort[] applications = { 0, 0, 0 };
{
0, 0, 0
};
readonly string[] names = readonly string[] names = { "000000", "32M ", "AF HMP" };
{
"000000", "32M ", "AF HMP"
};
readonly byte[] revisions = readonly byte[] revisions = { 0x07, 0x01, 0x10 };
{
0x07, 0x01, 0x10
};
readonly uint[] serials = readonly uint[] serials = { 0xb2021290, 0x1923a457, 0xa9000b1a };
{
0xb2021290, 0x1923a457, 0xa9000b1a
};
readonly byte[] dates = readonly byte[] dates = { 0x97, 0xc6, 0x68 };
{
0x97, 0xc6, 0x68
};
readonly byte[] crcs = readonly byte[] crcs = { 0x00, 0x00, 0x00 };
{
0x00, 0x00, 0x00
};
[Test] [Test]
public void Test() public void Test()
{ {
for(int i = 0; i < cards.Length; i++) for(var i = 0; i < cards.Length; i++)
{
using(new AssertionScope()) using(new AssertionScope())
{
Assert.Multiple(() => Assert.Multiple(() =>
{ {
int count = Marshal.ConvertFromHexAscii(cids[i], out byte[] response); int count = Marshal.ConvertFromHexAscii(cids[i], out byte[] response);
@@ -85,5 +63,7 @@ public class CID
Assert.AreEqual(crcs[i], cid.CRC, string.Format(Localization.CRC_0, cards[i])); Assert.AreEqual(crcs[i], cid.CRC, string.Format(Localization.CRC_0, cards[i]));
}); });
}
}
} }
} }

View File

@@ -11,176 +11,82 @@ namespace Aaru.Tests.Devices.MultiMediaCard;
[TestFixture] [TestFixture]
public class CSD public class CSD
{ {
readonly string[] cards = readonly string[] cards = { "mmc_6600_32mb", "mmc_pretec_32mb", "mmc_takems_256mb" };
{
"mmc_6600_32mb", "mmc_pretec_32mb", "mmc_takems_256mb"
};
readonly string[] csds = readonly string[] csds =
{ {
"8c26012a0f5901e9f6d983e392404001", "8c0e012a0ff981e9f6d981e18a400001", "905e002a1f5983d3edb683ff96400001" "8c26012a0f5901e9f6d983e392404001", "8c0e012a0ff981e9f6d981e18a400001", "905e002a1f5983d3edb683ff96400001"
}; };
readonly byte[] structure_versions = readonly byte[] structure_versions = { 2, 2, 2 };
{
2, 2, 2
};
readonly byte[] spec_versions = readonly byte[] spec_versions = { 3, 3, 4 };
{
3, 3, 4
};
readonly byte[] taacs = readonly byte[] taacs = { 38, 14, 94 };
{
38, 14, 94
};
readonly byte[] nsacs = readonly byte[] nsacs = { 1, 1, 0 };
{
1, 1, 0
};
readonly byte[] speeds = readonly byte[] speeds = { 42, 42, 42 };
{
42, 42, 42
};
readonly ushort[] classes = readonly ushort[] classes = { 245, 255, 501 };
{
245, 255, 501
};
readonly byte[] read_block_lengths = readonly byte[] read_block_lengths = { 9, 9, 9 };
{
9, 9, 9
};
readonly bool[] read_partial_blocks = readonly bool[] read_partial_blocks = { false, true, true };
{
false, true, true
};
readonly bool[] write_misaligned_block = readonly bool[] write_misaligned_block = { false, false, false };
{
false, false, false
};
readonly bool[] read_misaligned_block = readonly bool[] read_misaligned_block = { false, false, false };
{
false, false, false
};
readonly bool[] dsr_implemented = readonly bool[] dsr_implemented = { false, false, false };
{
false, false, false
};
readonly uint[] card_sizes = readonly uint[] card_sizes = { 1959, 1959, 3919 };
{
1959, 1959, 3919
};
readonly byte[] min_read_current = readonly byte[] min_read_current = { 6, 6, 5 };
{
6, 6, 5
};
readonly byte[] max_read_current = readonly byte[] max_read_current = { 6, 6, 5 };
{
6, 6, 5
};
readonly byte[] min_write_current = readonly byte[] min_write_current = { 6, 6, 5 };
{
6, 6, 5
};
readonly byte[] max_write_current = readonly byte[] max_write_current = { 6, 6, 5 };
{
6, 6, 5
};
readonly byte[] size_multiplier = readonly byte[] size_multiplier = { 3, 3, 5 };
{
3, 3, 5
};
readonly byte[] sector_sizes = readonly byte[] sector_sizes = { 0, 0, 0 };
{
0, 0, 0
};
readonly byte[] erase_sector_sizes = readonly byte[] erase_sector_sizes = { 31, 15, 31 };
{
31, 15, 31
};
readonly byte[] write_protect_group_size = readonly byte[] write_protect_group_size = { 3, 1, 31 };
{
3, 1, 31
};
readonly bool[] write_protect_group_enable = readonly bool[] write_protect_group_enable = { true, true, true };
{
true, true, true
};
readonly byte[] default_eccs = readonly byte[] default_eccs = { 0, 0, 0 };
{
0, 0, 0
};
readonly byte[] r2w_factors = readonly byte[] r2w_factors = { 4, 2, 5 };
{
4, 2, 5
};
readonly byte[] write_block_lengths = readonly byte[] write_block_lengths = { 9, 9, 9 };
{
9, 9, 9
};
readonly bool[] write_partial_blocks = readonly bool[] write_partial_blocks = { false, false, false };
{
false, false, false
};
readonly bool[] file_format_group = readonly bool[] file_format_group = { false, false, false };
{
false, false, false
};
readonly bool[] copy = readonly bool[] copy = { true, false, false };
{
true, false, false
};
readonly bool[] permanent_write_protect = readonly bool[] permanent_write_protect = { false, false, false };
{
false, false, false
};
readonly bool[] temporary_write_protect = readonly bool[] temporary_write_protect = { false, false, false };
{
false, false, false
};
readonly byte[] file_format = readonly byte[] file_format = { 0, 0, 0 };
{
0, 0, 0
};
readonly byte[] ecc = readonly byte[] ecc = { 0, 0, 0 };
{
0, 0, 0
};
[Test] [Test]
public void Test() public void Test()
{ {
for(int i = 0; i < cards.Length; i++) for(var i = 0; i < cards.Length; i++)
{
using(new AssertionScope()) using(new AssertionScope())
{
Assert.Multiple(() => Assert.Multiple(() =>
{ {
int count = Marshal.ConvertFromHexAscii(csds[i], out byte[] response); int count = Marshal.ConvertFromHexAscii(csds[i], out byte[] response);
@@ -194,10 +100,10 @@ public class CSD
Assert.AreEqual(spec_versions[i], csd.Version, Assert.AreEqual(spec_versions[i], csd.Version,
string.Format(Localization.Specification_version_0, cards[i])); string.Format(Localization.Specification_version_0, cards[i]));
Assert.AreEqual(taacs[i], csd.TAAC, string.Format(Localization.TAAC_0, cards[i])); Assert.AreEqual(taacs[i], csd.TAAC, string.Format(Localization.TAAC_0, cards[i]));
Assert.AreEqual(nsacs[i], csd.NSAC, string.Format(Localization.NSAC_0, cards[i])); Assert.AreEqual(nsacs[i], csd.NSAC, string.Format(Localization.NSAC_0, cards[i]));
Assert.AreEqual(speeds[i], csd.Speed, string.Format(Localization.Transfer_speed_0, cards[i])); Assert.AreEqual(speeds[i], csd.Speed, string.Format(Localization.Transfer_speed_0, cards[i]));
Assert.AreEqual(classes[i], csd.Classes, string.Format(Localization.Classes_0, cards[i])); Assert.AreEqual(classes[i], csd.Classes, string.Format(Localization.Classes_0, cards[i]));
Assert.AreEqual(read_block_lengths[i], csd.ReadBlockLength, Assert.AreEqual(read_block_lengths[i], csd.ReadBlockLength,
string.Format(Localization.Read_block_length_0, cards[i])); string.Format(Localization.Read_block_length_0, cards[i]));
@@ -271,5 +177,7 @@ public class CSD
Assert.AreEqual(ecc[i], csd.ECC, string.Format(Localization.ECC_0, cards[i])); Assert.AreEqual(ecc[i], csd.ECC, string.Format(Localization.ECC_0, cards[i]));
}); });
}
}
} }
} }

View File

@@ -11,35 +11,38 @@ public class ExtendedCSD
{ {
new byte[] new byte[]
{ {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x13, 0x00, 0x07, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x15, 0x1F, 0x20, 0x00, 0x00, 0x00, 0x00, 0x11, 0x05, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x13, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x02, 0x00, 0x57, 0x01, 0x07, 0x01, 0x01, 0x00, 0x00, 0x00, 0x15, 0x1F, 0x20, 0x00, 0x00, 0x00, 0x00, 0x11, 0x05, 0x01,
0x05, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0xC0, 0x33, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x10, 0x16, 0x00, 0x07, 0x07, 0x08, 0x01, 0x05, 0x01, 0x06, 0x20, 0x00, 0x07, 0x11, 0x1B, 0x55, 0x05, 0x00, 0x08, 0x00, 0x02, 0x00, 0x57, 0x01, 0x05, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x0A, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0xC0, 0x33, 0x07, 0x10, 0x16, 0x00, 0x07, 0x07, 0x08, 0x01, 0x05,
0x00, 0x00, 0x1B, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x20, 0x00, 0x01, 0x01, 0x01, 0x01, 0x06, 0x20, 0x00, 0x07, 0x11, 0x1B, 0x55, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x0A, 0x00, 0x00, 0x01, 0x00, 0x00, 0x1B, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x20, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00,
0x00, 0x1F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x07, 0x05, 0x00, 0x03, 0x01, 0x3F, 0x3F, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x07,
0x05, 0x00, 0x03, 0x01, 0x3F, 0x3F, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
} }
}; };
@@ -85,134 +88,131 @@ public class ExtendedCSD
GeneralPurposePartitionSize = new byte[12], GeneralPurposePartitionSize = new byte[12],
PartitioningSetting = 0, PartitioningSetting = 0,
PartitionsAttribute = 0, PartitionsAttribute = 0,
MaxEnhancedAreaSize = new byte[] MaxEnhancedAreaSize = new byte[] { 52, 19, 0 },
{ PartitioningSupport = (PartitioningSupport)7,
52, 19, 0 HPIManagement = 1,
}, HWResetFunction = 1,
PartitioningSupport = (PartitioningSupport)7, EnableBackgroundOperationsHandshake = 0,
HPIManagement = 1, ManuallyStartBackgroundOperations = 0,
HWResetFunction = 1, StartSanitizeOperation = 0,
EnableBackgroundOperationsHandshake = 0, WriteReliabilityParameterRegister = 21,
ManuallyStartBackgroundOperations = 0, WriteReliabilitySettingRegister = 31,
StartSanitizeOperation = 0, RPMBSize = 32,
WriteReliabilityParameterRegister = 21, FirmwareConfiguration = 0,
WriteReliabilitySettingRegister = 31, Reserved4 = 0,
RPMBSize = 32, UserAreaWriteProtectionRegister = 0,
FirmwareConfiguration = 0, Reserved5 = 0,
Reserved4 = 0, BootAreaWriteProtectionRegister = (BootAreaWriteProtectionRegister)17,
UserAreaWriteProtectionRegister = 0, BootWriteProtectionStatus = 5,
Reserved5 = 0, HighCapacityEraseGroupDefinition = (HighCapacityEraseGroupDefinition)1,
BootAreaWriteProtectionRegister = (BootAreaWriteProtectionRegister)17, Reserved6 = 0,
BootWriteProtectionStatus = 5, BootBusConditions = 0,
HighCapacityEraseGroupDefinition = (HighCapacityEraseGroupDefinition)1, BootConfigProtection = 0,
Reserved6 = 0, PartitionConfiguration = 0,
BootBusConditions = 0, Reserved7 = 0,
BootConfigProtection = 0, ErasedMemoryContent = 0,
PartitionConfiguration = 0, Reserved8 = 0,
Reserved7 = 0, BusWidth = 0,
ErasedMemoryContent = 0, StrobeSupport = 1,
Reserved8 = 0, HighSpeedInterfaceTiming = 3,
BusWidth = 0, Reserved9 = 0,
StrobeSupport = 1, PowerClass = 0,
HighSpeedInterfaceTiming = 3, Reserved10 = 0,
Reserved9 = 0, CommandSetRevision = 0,
PowerClass = 0, Reserved11 = 0,
Reserved10 = 0, CommandSet = 0,
CommandSetRevision = 0, Revision = 8,
Reserved11 = 0, Reserved12 = 0,
CommandSet = 0, Structure = 2,
Revision = 8, Reserved13 = 0,
Reserved12 = 0, DeviceType = (DeviceType)87,
Structure = 2, DriverStrength = (DriverStrength)1,
Reserved13 = 0, OutOfInterruptBusyTiming = 5,
DeviceType = (DeviceType)87, PartitionSwitchingTime = 10,
DriverStrength = (DriverStrength)1, PowerClass52_195 = 0,
OutOfInterruptBusyTiming = 5, PowerClass26_195 = 0,
PartitionSwitchingTime = 10, PowerClass52 = 0,
PowerClass52_195 = 0, PowerClass26 = 0,
PowerClass26_195 = 0, Reserved14 = 0,
PowerClass52 = 0, MinimumReadPerformance26_4 = 0,
PowerClass26 = 0, MinimumWritePerformance26_4 = 0,
Reserved14 = 0, MinimumReadPerformance26 = 0,
MinimumReadPerformance26_4 = 0, MinimumWritePerformance26 = 0,
MinimumWritePerformance26_4 = 0, MinimumReadPerformance52 = 0,
MinimumReadPerformance26 = 0, MinimumWritePerformance52 = 0,
MinimumWritePerformance26 = 0, SecureWriteProtectInformation = (SecureWriteProtectInformation)1,
MinimumReadPerformance52 = 0, SectorCount = 120832000,
MinimumWritePerformance52 = 0, SleepNotificationTimeout = 16,
SecureWriteProtectInformation = (SecureWriteProtectInformation)1, SleepAwakeTimeout = 22,
SectorCount = 120832000, ProductionStateAwarenessTimeout = 0,
SleepNotificationTimeout = 16, SleepCurrentVccQ = 7,
SleepAwakeTimeout = 22, SleepCurrentVcc = 7,
ProductionStateAwarenessTimeout = 0, HighCapacityWriteProtectGroupSize = 8,
SleepCurrentVccQ = 7, ReliableWriteSectorCount = 1,
SleepCurrentVcc = 7, HighCapacityEraseTimeout = 5,
HighCapacityWriteProtectGroupSize = 8, HighCapacityEraseUnitSize = 1,
ReliableWriteSectorCount = 1, AccessSize = 6,
HighCapacityEraseTimeout = 5, BootPartitionSize = 32,
HighCapacityEraseUnitSize = 1, Reserved15 = 0,
AccessSize = 6, BootInformation = (BootInformation)7,
BootPartitionSize = 32, SecureTRIMMultiplier = 17,
Reserved15 = 0, SecureEraseMultiplier = 27,
BootInformation = (BootInformation)7, SecureFeatureSupport = (SecureFeatureSupport)85,
SecureTRIMMultiplier = 17, TRIMMultiplier = 5,
SecureEraseMultiplier = 27, Reserved16 = 0,
SecureFeatureSupport = (SecureFeatureSupport)85, MinimumReadPerformanceDDR52 = 0,
TRIMMultiplier = 5, MinimumWritePerformanceDDR52 = 0,
Reserved16 = 0, PowerClassDDR200_130 = 0,
MinimumReadPerformanceDDR52 = 0, PowerClassDDR200_195 = 0,
MinimumWritePerformanceDDR52 = 0, PowerClassDDR52_195 = 0,
PowerClassDDR200_130 = 0, PowerClassDDR52 = 0,
PowerClassDDR200_195 = 0, CacheFlushingPolicy = 0,
PowerClassDDR52_195 = 0, InitializationTimeAfterPartition = 30,
PowerClassDDR52 = 0, CorrectlyProgrammedSectors = 0,
CacheFlushingPolicy = 0, BackgroundOperationsStatus = 0,
InitializationTimeAfterPartition = 30, PowerOffNotificationTimeout = 60,
CorrectlyProgrammedSectors = 0, GenericCMD6Timeout = 10,
BackgroundOperationsStatus = 0, CacheSize = 65536,
PowerOffNotificationTimeout = 60, PowerClassDDR200 = 0,
GenericCMD6Timeout = 10, FirmwareVersion = 283,
CacheSize = 65536, DeviceVersion = 0,
PowerClassDDR200 = 0, OptimalTrimUnitSize = 1,
FirmwareVersion = 283, OptimalWriteSize = 32,
DeviceVersion = 0, OptimalReadSize = 0,
OptimalTrimUnitSize = 1, PreEOLInformation = 1,
OptimalWriteSize = 32, DeviceLifeEstimationTypeA = 1,
OptimalReadSize = 0, DeviceLifeEstimationTypeB = 1,
PreEOLInformation = 1, VendorHealthReport = new byte[32],
DeviceLifeEstimationTypeA = 1, NumberOfFWSectorsCorrectlyProgrammed = 0,
DeviceLifeEstimationTypeB = 1, Reserved17 = 0,
VendorHealthReport = new byte[32], CMDQueuingDepth = 31,
NumberOfFWSectorsCorrectlyProgrammed = 0, CMDQueuingSupport = (CMDQueuingSupport)1,
Reserved17 = 0, Reserved18 = new byte[177],
CMDQueuingDepth = 31, BarrierSupport = 0,
CMDQueuingSupport = (CMDQueuingSupport)1, FFUArgument = 0,
Reserved18 = new byte[177], OperationCodesTimeout = 0,
BarrierSupport = 0, FFUFeatures = 0,
FFUArgument = 0, SupportedModes = (SupportedModes)3,
OperationCodesTimeout = 0, ExtendedPartitionsSupport = (ExtendedPartitionsSupport)3,
FFUFeatures = 0, LargeUnitSize = 7,
SupportedModes = (SupportedModes)3, ContextManagementCaps = 5,
ExtendedPartitionsSupport = (ExtendedPartitionsSupport)3, TagResourcesSize = 0,
LargeUnitSize = 7, TagUnitSize = 3,
ContextManagementCaps = 5, DataTagSupport = (DataTagSupport)1,
TagResourcesSize = 0, MaxPackedWriteCommands = 63,
TagUnitSize = 3, MaxPackedReadCommands = 63,
DataTagSupport = (DataTagSupport)1, BackgroundOperationsSupport = (BackgroundOperationsSupport)1,
MaxPackedWriteCommands = 63, HPIFeatures = (HPIFeatures)1,
MaxPackedReadCommands = 63, SupportedCommandSets = (DeviceSupportedCommandSets)1,
BackgroundOperationsSupport = (BackgroundOperationsSupport)1, ExtendedSecurityCommandsError = 0,
HPIFeatures = (HPIFeatures)1, Reserved19 = new byte[6]
SupportedCommandSets = (DeviceSupportedCommandSets)1,
ExtendedSecurityCommandsError = 0,
Reserved19 = new byte[6]
} }
}; };
[Test] [Test]
public void Test() public void Test()
{ {
for(int i = 0; i < _ecsd.Length; i++) for(var i = 0; i < _ecsd.Length; i++)
{ {
Decoders.MMC.ExtendedCSD csd = Decoders.MMC.Decoders.DecodeExtendedCSD(_ecsd[i]); Decoders.MMC.ExtendedCSD csd = Decoders.MMC.Decoders.DecodeExtendedCSD(_ecsd[i]);
Assert.IsNotNull(csd, string.Format(Localization.Not_decoded_0, i)); Assert.IsNotNull(csd, string.Format(Localization.Not_decoded_0, i));

View File

@@ -40,25 +40,13 @@ namespace Aaru.Tests.Devices;
[TestFixture] [TestFixture]
public class PocketZip public class PocketZip
{ {
readonly string[] _testFiles = readonly string[] _testFiles = { "clik!.bin.lz", "pocketzip.bin.lz" };
{
"clik!.bin.lz", "pocketzip.bin.lz"
};
readonly MediaType[] _mediaTypes = readonly MediaType[] _mediaTypes = { MediaType.PocketZip, MediaType.PocketZip };
{
MediaType.PocketZip, MediaType.PocketZip
};
readonly ulong[] _sectors = readonly ulong[] _sectors = { 78882, 78882 };
{
78882, 78882
};
readonly uint[] _sectorSize = readonly uint[] _sectorSize = { 512, 512 };
{
512, 512
};
readonly string _dataFolder = Path.Combine(Consts.TestFilesRoot, "Device test dumps", "PocketZIP"); readonly string _dataFolder = Path.Combine(Consts.TestFilesRoot, "Device test dumps", "PocketZIP");
@@ -69,7 +57,7 @@ public class PocketZip
Assert.Multiple(() => Assert.Multiple(() =>
{ {
for(int i = 0; i < _testFiles.Length; i++) for(var i = 0; i < _testFiles.Length; i++)
{ {
var filter = new LZip(); var filter = new LZip();
filter.Open(_testFiles[i]); filter.Open(_testFiles[i]);
@@ -83,6 +71,7 @@ public class PocketZip
continue; continue;
using(new AssertionScope()) using(new AssertionScope())
{
Assert.Multiple(() => Assert.Multiple(() =>
{ {
Assert.AreEqual(_sectors[i], image.Info.Sectors, Assert.AreEqual(_sectors[i], image.Info.Sectors,
@@ -94,6 +83,7 @@ public class PocketZip
Assert.AreEqual(_mediaTypes[i], image.Info.MediaType, Assert.AreEqual(_mediaTypes[i], image.Info.MediaType,
string.Format(Localization.Media_type_0, _testFiles[i])); string.Format(Localization.Media_type_0, _testFiles[i]));
}); });
}
} }
}); });
} }

View File

@@ -40,10 +40,7 @@ public class CID
"TO", "SD064" "TO", "SD064"
}; };
readonly byte[] revisions = readonly byte[] revisions = { 0x60, 0x38, 0x04, 0x10, 0x38, 0x80, 0x80, 0x10, 0x10, 0x30, 0x10, 0x80, 0xff, 0x05 };
{
0x60, 0x38, 0x04, 0x10, 0x38, 0x80, 0x80, 0x10, 0x10, 0x30, 0x10, 0x80, 0xff, 0x05
};
readonly uint[] serials = readonly uint[] serials =
{ {
@@ -56,16 +53,15 @@ public class CID
0x147, 0x089, 0x09a, 0x0a5, 0x091, 0x0e8, 0x123, 0x0b2, 0x067, 0x0b8, 0x0aa, 0x095, 0x0fa, 0x034 0x147, 0x089, 0x09a, 0x0a5, 0x091, 0x0e8, 0x123, 0x0b2, 0x067, 0x0b8, 0x0aa, 0x095, 0x0fa, 0x034
}; };
readonly byte[] crcs = readonly byte[] crcs = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
[Test] [Test]
public void Test() public void Test()
{ {
for(int i = 0; i < cards.Length; i++) for(var i = 0; i < cards.Length; i++)
{
using(new AssertionScope()) using(new AssertionScope())
{
Assert.Multiple(() => Assert.Multiple(() =>
{ {
int count = Marshal.ConvertFromHexAscii(cids[i], out byte[] response); int count = Marshal.ConvertFromHexAscii(cids[i], out byte[] response);
@@ -92,5 +88,7 @@ public class CID
Assert.AreEqual(crcs[i], cid.CRC, string.Format(Localization.CRC_0, cards[i])); Assert.AreEqual(crcs[i], cid.CRC, string.Format(Localization.CRC_0, cards[i]));
}); });
}
}
} }
} }

View File

@@ -25,20 +25,11 @@ public class CSD
"400e00325b5900001dbf7f800a400001", "002d0032135983c9f6d9cf8016400001" "400e00325b5900001dbf7f800a400001", "002d0032135983c9f6d9cf8016400001"
}; };
readonly byte[] structure_versions = readonly byte[] structure_versions = { 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0 };
{
1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0
};
readonly byte[] taacs = readonly byte[] taacs = { 14, 14, 14, 38, 46, 14, 14, 127, 94, 14, 14, 14, 14, 45 };
{
14, 14, 14, 38, 46, 14, 14, 127, 94, 14, 14, 14, 14, 45
};
readonly byte[] nsacs = readonly byte[] nsacs = { 0, 0, 0, 1, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0 };
{
0, 0, 0, 1, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0
};
readonly byte[] speeds = readonly byte[] speeds =
{ {
@@ -46,15 +37,9 @@ public class CSD
50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50
}; };
readonly ushort[] classes = readonly ushort[] classes = { 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1397, 1461, 1461, 1461, 1461, 309 };
{
1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1397, 1461, 1461, 1461, 1461, 309
};
readonly byte[] read_block_lengths = readonly byte[] read_block_lengths = { 9, 9, 9, 10, 10, 9, 9, 10, 11, 9, 9, 9, 9, 9 };
{
9, 9, 9, 10, 10, 9, 9, 10, 11, 9, 9, 9, 9, 9
};
readonly bool[] read_partial_blocks = readonly bool[] read_partial_blocks =
{ {
@@ -81,55 +66,31 @@ public class CSD
29711, 7559, 15207, 3871, 3751, 30386, 60872, 3819, 3925, 7591, 7659, 7562, 7615, 3879 29711, 7559, 15207, 3871, 3751, 30386, 60872, 3819, 3925, 7591, 7659, 7562, 7615, 3879
}; };
readonly byte[] min_read_current = readonly byte[] min_read_current = { 0, 0, 0, 6, 7, 0, 0, 6, 5, 0, 0, 0, 0, 6 };
{
0, 0, 0, 6, 7, 0, 0, 6, 5, 0, 0, 0, 0, 6
};
readonly byte[] max_read_current = readonly byte[] max_read_current = { 0, 0, 0, 6, 7, 0, 0, 6, 5, 0, 0, 0, 0, 6 };
{
0, 0, 0, 6, 7, 0, 0, 6, 5, 0, 0, 0, 0, 6
};
readonly byte[] min_write_current = readonly byte[] min_write_current = { 0, 0, 0, 6, 7, 0, 0, 6, 5, 0, 0, 0, 0, 6 };
{
0, 0, 0, 6, 7, 0, 0, 6, 5, 0, 0, 0, 0, 6
};
readonly byte[] max_write_current = readonly byte[] max_write_current = { 0, 0, 0, 6, 7, 0, 0, 6, 5, 0, 0, 0, 0, 6 };
{
0, 0, 0, 6, 7, 0, 0, 6, 5, 0, 0, 0, 0, 6
};
readonly byte[] size_multiplier = readonly byte[] size_multiplier = { 0, 0, 0, 7, 7, 0, 0, 7, 7, 0, 0, 0, 0, 3 };
{
0, 0, 0, 7, 7, 0, 0, 7, 7, 0, 0, 0, 0, 3
};
readonly bool[] erase_block_enable = readonly bool[] erase_block_enable =
{ {
true, true, true, true, true, true, true, true, true, true, true, true, true, true true, true, true, true, true, true, true, true, true, true, true, true, true, true
}; };
readonly byte[] erase_sector_sizes = readonly byte[] erase_sector_sizes = { 127, 127, 127, 127, 127, 127, 127, 63, 127, 127, 127, 127, 127, 31 };
{
127, 127, 127, 127, 127, 127, 127, 63, 127, 127, 127, 127, 127, 31
};
readonly byte[] write_protect_group_size = readonly byte[] write_protect_group_size = { 0, 0, 0, 31, 0, 0, 0, 127, 127, 0, 0, 0, 0, 0 };
{
0, 0, 0, 31, 0, 0, 0, 127, 127, 0, 0, 0, 0, 0
};
readonly bool[] write_protect_group_enable = readonly bool[] write_protect_group_enable =
{ {
false, false, false, false, false, false, false, false, true, false, false, false, false, false false, false, false, false, false, false, false, false, true, false, false, false, false, false
}; };
readonly byte[] r2w_factors = readonly byte[] r2w_factors = { 2, 2, 2, 5, 5, 2, 2, 3, 5, 2, 2, 2, 2, 5 };
{
2, 2, 2, 5, 5, 2, 2, 3, 5, 2, 2, 2, 2, 5
};
readonly bool[] file_format_group = readonly bool[] file_format_group =
{ {
@@ -151,16 +112,15 @@ public class CSD
false, false, false, false, false, false, false, false, false, false, false, false, false, false false, false, false, false, false, false, false, false, false, false, false, false, false, false
}; };
readonly byte[] file_format = readonly byte[] file_format = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
[Test] [Test]
public void Test() public void Test()
{ {
for(int i = 0; i < cards.Length; i++) for(var i = 0; i < cards.Length; i++)
{
using(new AssertionScope()) using(new AssertionScope())
{
Assert.Multiple(() => Assert.Multiple(() =>
{ {
int count = Marshal.ConvertFromHexAscii(csds[i], out byte[] response); int count = Marshal.ConvertFromHexAscii(csds[i], out byte[] response);
@@ -171,10 +131,10 @@ public class CSD
Assert.AreEqual(structure_versions[i], csd.Structure, Assert.AreEqual(structure_versions[i], csd.Structure,
string.Format(Localization.Version_0, cards[i])); string.Format(Localization.Version_0, cards[i]));
Assert.AreEqual(taacs[i], csd.TAAC, string.Format(Localization.TAAC_0, cards[i])); Assert.AreEqual(taacs[i], csd.TAAC, string.Format(Localization.TAAC_0, cards[i]));
Assert.AreEqual(nsacs[i], csd.NSAC, string.Format(Localization.NSAC_0, cards[i])); Assert.AreEqual(nsacs[i], csd.NSAC, string.Format(Localization.NSAC_0, cards[i]));
Assert.AreEqual(speeds[i], csd.Speed, string.Format(Localization.Transfer_speed_0, cards[i])); Assert.AreEqual(speeds[i], csd.Speed, string.Format(Localization.Transfer_speed_0, cards[i]));
Assert.AreEqual(classes[i], csd.Classes, string.Format(Localization.Classes_0, cards[i])); Assert.AreEqual(classes[i], csd.Classes, string.Format(Localization.Classes_0, cards[i]));
Assert.AreEqual(read_block_lengths[i], csd.ReadBlockLength, Assert.AreEqual(read_block_lengths[i], csd.ReadBlockLength,
string.Format(Localization.Read_block_length_0, cards[i])); string.Format(Localization.Read_block_length_0, cards[i]));
@@ -237,5 +197,7 @@ public class CSD
Assert.AreEqual(file_format[i], csd.FileFormat, Assert.AreEqual(file_format[i], csd.FileFormat,
string.Format(Localization.File_format_0, cards[i])); string.Format(Localization.File_format_0, cards[i]));
}); });
}
}
} }
} }

View File

@@ -24,121 +24,53 @@ public class SCR
"0235000000000000", "0235000000000000", "02b5800000000000", "00a5000008070302" "0235000000000000", "0235000000000000", "02b5800000000000", "00a5000008070302"
}; };
readonly byte[] structure_version = readonly byte[] structure_version = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
readonly byte[] specification_version = readonly byte[] specification_version = { 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 0 };
{
2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 0
};
readonly bool[] data_stat_after_erase = readonly bool[] data_stat_after_erase =
{ {
false, true, false, true, true, false, false, false, false, false, false, false, true, true false, true, false, true, true, false, false, false, false, false, false, false, true, true
}; };
readonly byte[] sd_security = readonly byte[] sd_security = { 0, 3, 3, 2, 2, 3, 3, 2, 2, 3, 3, 3, 3, 2 };
{
0, 3, 3, 2, 2, 3, 3, 2, 2, 3, 3, 3, 3, 2
};
readonly byte[] sd_bus_widths = readonly byte[] sd_bus_widths = { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 };
{
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5
};
readonly bool[] sd_spec3 = readonly bool[] sd_spec3 =
{ {
true, false, true, false, false, true, true, true, false, true, false, false, true, false true, false, true, false, false, true, true, true, false, true, false, false, true, false
}; };
readonly byte[] ex_security = readonly byte[] ex_security = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
readonly bool[] sd_spec4 = readonly bool[] sd_spec4 =
{ {
false, false, false, false, false, false, false, false, false, false, false, false, false, false false, false, false, false, false, false, false, false, false, false, false, false, false, false
}; };
readonly byte[] sd_specx = readonly byte[] sd_specx = { 2, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 };
{
2, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0
};
readonly byte[] cmd_support = readonly byte[] cmd_support = { 3, 0, 0, 0, 0, 1, 3, 0, 0, 0, 0, 0, 0, 0 };
{
3, 0, 0, 0, 0, 1, 3, 0, 0, 0, 0, 0, 0, 0
};
readonly byte[][] mfg = readonly byte[][] mfg =
{ {
new byte[] new byte[] { 0x01, 0x00, 0x00, 0x00 }, new byte[] { 0x1c, 0x02, 0x21, 0x02 },
{ new byte[] { 0x01, 0x00, 0x00, 0x00 }, new byte[] { 0x00, 0x00, 0x00, 0x00 },
0x01, 0x00, 0x00, 0x00 new byte[] { 0x1c, 0x02, 0x14, 0x02 }, new byte[] { 0x00, 0x00, 0x00, 0x00 },
}, new byte[] { 0x00, 0x00, 0x00, 0x00 }, new byte[] { 0x00, 0x00, 0x00, 0x00 },
new byte[] new byte[] { 0x00, 0x00, 0x00, 0x00 }, new byte[] { 0x01, 0x00, 0x00, 0x00 },
{ new byte[] { 0x00, 0x00, 0x00, 0x00 }, new byte[] { 0x00, 0x00, 0x00, 0x00 },
0x1c, 0x02, 0x21, 0x02 new byte[] { 0x00, 0x00, 0x00, 0x00 }, new byte[] { 0x08, 0x07, 0x03, 0x02 }
},
new byte[]
{
0x01, 0x00, 0x00, 0x00
},
new byte[]
{
0x00, 0x00, 0x00, 0x00
},
new byte[]
{
0x1c, 0x02, 0x14, 0x02
},
new byte[]
{
0x00, 0x00, 0x00, 0x00
},
new byte[]
{
0x00, 0x00, 0x00, 0x00
},
new byte[]
{
0x00, 0x00, 0x00, 0x00
},
new byte[]
{
0x00, 0x00, 0x00, 0x00
},
new byte[]
{
0x01, 0x00, 0x00, 0x00
},
new byte[]
{
0x00, 0x00, 0x00, 0x00
},
new byte[]
{
0x00, 0x00, 0x00, 0x00
},
new byte[]
{
0x00, 0x00, 0x00, 0x00
},
new byte[]
{
0x08, 0x07, 0x03, 0x02
}
}; };
[Test] [Test]
public void Test() public void Test()
{ {
for(int i = 0; i < cards.Length; i++) for(var i = 0; i < cards.Length; i++)
{
using(new AssertionScope()) using(new AssertionScope())
{
Assert.Multiple(() => Assert.Multiple(() =>
{ {
int count = Marshal.ConvertFromHexAscii(scrs[i], out byte[] response); int count = Marshal.ConvertFromHexAscii(scrs[i], out byte[] response);
@@ -174,5 +106,7 @@ public class SCR
Assert.AreEqual(mfg[i], scr.ManufacturerReserved, Assert.AreEqual(mfg[i], scr.ManufacturerReserved,
string.Format(Localization.Manufacturer_reserved_0, cards[i])); string.Format(Localization.Manufacturer_reserved_0, cards[i]));
}); });
}
}
} }
} }

View File

@@ -41,6 +41,7 @@ public class APM : FilesystemTest
public override string DataFolder => public override string DataFolder =>
Path.Combine(Consts.TestFilesRoot, "Filesystems", "Amiga Fast File System (APM)"); Path.Combine(Consts.TestFilesRoot, "Filesystems", "Amiga Fast File System (APM)");
public override IFilesystem Plugin => new AmigaDOSPlugin(); public override IFilesystem Plugin => new AmigaDOSPlugin();
public override bool Partitions => true; public override bool Partitions => true;

View File

@@ -35,13 +35,15 @@ using NUnit.Framework;
namespace Aaru.Tests.Filesystems.AFFS; namespace Aaru.Tests.Filesystems.AFFS;
[TestFixture, SuppressMessage("ReSharper", "InconsistentNaming")] [TestFixture]
[SuppressMessage("ReSharper", "InconsistentNaming")]
public class MBR_RDB : FilesystemTest public class MBR_RDB : FilesystemTest
{ {
public MBR_RDB() : base("affs") {} public MBR_RDB() : base("affs") {}
public override string DataFolder => public override string DataFolder =>
Path.Combine(Consts.TestFilesRoot, "Filesystems", "Amiga Fast File System (MBR+RDB)"); Path.Combine(Consts.TestFilesRoot, "Filesystems", "Amiga Fast File System (MBR+RDB)");
public override IFilesystem Plugin => new AmigaDOSPlugin(); public override IFilesystem Plugin => new AmigaDOSPlugin();
public override bool Partitions => true; public override bool Partitions => true;

View File

@@ -41,6 +41,7 @@ public class MBR : FilesystemTest
public override string DataFolder => public override string DataFolder =>
Path.Combine(Consts.TestFilesRoot, "Filesystems", "Amiga Fast File System (MBR)"); Path.Combine(Consts.TestFilesRoot, "Filesystems", "Amiga Fast File System (MBR)");
public override IFilesystem Plugin => new AmigaDOSPlugin(); public override IFilesystem Plugin => new AmigaDOSPlugin();
public override bool Partitions => true; public override bool Partitions => true;

View File

@@ -41,6 +41,7 @@ public class RDB : FilesystemTest
public override string DataFolder => public override string DataFolder =>
Path.Combine(Consts.TestFilesRoot, "Filesystems", "Amiga Fast File System (RDB)"); Path.Combine(Consts.TestFilesRoot, "Filesystems", "Amiga Fast File System (RDB)");
public override IFilesystem Plugin => new AmigaDOSPlugin(); public override IFilesystem Plugin => new AmigaDOSPlugin();
public override bool Partitions => true; public override bool Partitions => true;

View File

@@ -35,13 +35,15 @@ using NUnit.Framework;
namespace Aaru.Tests.Filesystems.AOFS; namespace Aaru.Tests.Filesystems.AOFS;
[TestFixture, SuppressMessage("ReSharper", "InconsistentNaming")] [TestFixture]
[SuppressMessage("ReSharper", "InconsistentNaming")]
public class MBR_RDB : FilesystemTest public class MBR_RDB : FilesystemTest
{ {
public MBR_RDB() : base("aofs") {} public MBR_RDB() : base("aofs") {}
public override string DataFolder => public override string DataFolder =>
Path.Combine(Consts.TestFilesRoot, "Filesystems", "Amiga Old File System (MBR+RDB)"); Path.Combine(Consts.TestFilesRoot, "Filesystems", "Amiga Old File System (MBR+RDB)");
public override IFilesystem Plugin => new AmigaDOSPlugin(); public override IFilesystem Plugin => new AmigaDOSPlugin();
public override bool Partitions => true; public override bool Partitions => true;

View File

@@ -41,6 +41,7 @@ public class MBR : FilesystemTest
public override string DataFolder => public override string DataFolder =>
Path.Combine(Consts.TestFilesRoot, "Filesystems", "Amiga Old File System (MBR)"); Path.Combine(Consts.TestFilesRoot, "Filesystems", "Amiga Old File System (MBR)");
public override IFilesystem Plugin => new AmigaDOSPlugin(); public override IFilesystem Plugin => new AmigaDOSPlugin();
public override bool Partitions => true; public override bool Partitions => true;

View File

@@ -41,6 +41,7 @@ public class RDB : FilesystemTest
public override string DataFolder => public override string DataFolder =>
Path.Combine(Consts.TestFilesRoot, "Filesystems", "Amiga Old File System (RDB)"); Path.Combine(Consts.TestFilesRoot, "Filesystems", "Amiga Old File System (RDB)");
public override IFilesystem Plugin => new AmigaDOSPlugin(); public override IFilesystem Plugin => new AmigaDOSPlugin();
public override bool Partitions => true; public override bool Partitions => true;

View File

@@ -33,7 +33,8 @@ using NUnit.Framework;
namespace Aaru.Tests.Filesystems.CPM; namespace Aaru.Tests.Filesystems.CPM;
[TestFixture, SuppressMessage("ReSharper", "InconsistentNaming")] [TestFixture]
[SuppressMessage("ReSharper", "InconsistentNaming")]
public class AMSDOS : FilesystemTest public class AMSDOS : FilesystemTest
{ {
public AMSDOS() : base("cpmfs") {} public AMSDOS() : base("cpmfs") {}

View File

@@ -33,7 +33,8 @@ using NUnit.Framework;
namespace Aaru.Tests.Filesystems.CPM; namespace Aaru.Tests.Filesystems.CPM;
[TestFixture, SuppressMessage("ReSharper", "InconsistentNaming")] [TestFixture]
[SuppressMessage("ReSharper", "InconsistentNaming")]
public class KayproII : ReadOnlyFilesystemTest public class KayproII : ReadOnlyFilesystemTest
{ {
public KayproII() : base("cpmfs") {} public KayproII() : base("cpmfs") {}

View File

@@ -33,7 +33,8 @@ using NUnit.Framework;
namespace Aaru.Tests.Filesystems.CPM; namespace Aaru.Tests.Filesystems.CPM;
[TestFixture, SuppressMessage("ReSharper", "InconsistentNaming")] [TestFixture]
[SuppressMessage("ReSharper", "InconsistentNaming")]
public class Plus3DOS : FilesystemTest public class Plus3DOS : FilesystemTest
{ {
public Plus3DOS() : base("cpmfs") {} public Plus3DOS() : base("cpmfs") {}

View File

@@ -33,7 +33,8 @@ using NUnit.Framework;
namespace Aaru.Tests.Filesystems.CPM; namespace Aaru.Tests.Filesystems.CPM;
[TestFixture, SuppressMessage("ReSharper", "InconsistentNaming")] [TestFixture]
[SuppressMessage("ReSharper", "InconsistentNaming")]
public class ROMDOS : FilesystemTest public class ROMDOS : FilesystemTest
{ {
public ROMDOS() : base("cpmfs") {} public ROMDOS() : base("cpmfs") {}

View File

@@ -65,7 +65,7 @@ public abstract class FilesystemTest
Assert.Greater(partitionsList.Count, 0, Assert.Greater(partitionsList.Count, 0,
string.Format(Localization.No_partitions_found_for_0, testFile)); string.Format(Localization.No_partitions_found_for_0, testFile));
bool found = false; var found = false;
foreach(Partition p in partitionsList) foreach(Partition p in partitionsList)
{ {
@@ -136,8 +136,8 @@ public abstract class FilesystemTest
Assert.AreEqual(ErrorNumber.NoError, image.Open(inputFilter), Assert.AreEqual(ErrorNumber.NoError, image.Open(inputFilter),
string.Format(Localization.Cannot_open_image_for_0, testFile)); string.Format(Localization.Cannot_open_image_for_0, testFile));
Assert.AreEqual(test.MediaType, image.Info.MediaType, testFile); Assert.AreEqual(test.MediaType, image.Info.MediaType, testFile);
Assert.AreEqual(test.Sectors, image.Info.Sectors, testFile); Assert.AreEqual(test.Sectors, image.Info.Sectors, testFile);
Assert.AreEqual(test.SectorSize, image.Info.SectorSize, testFile); Assert.AreEqual(test.SectorSize, image.Info.SectorSize, testFile);
} }
}); });
@@ -153,7 +153,7 @@ public abstract class FilesystemTest
foreach(FileSystemTest test in Tests) foreach(FileSystemTest test in Tests)
{ {
string testFile = test.TestFile; string testFile = test.TestFile;
bool found = false; var found = false;
var partition = new Partition(); var partition = new Partition();
bool exists = File.Exists(testFile); bool exists = File.Exists(testFile);
@@ -233,8 +233,10 @@ public abstract class FilesystemTest
fs.GetInformation(image, partition, null, out _, out FileSystem fsMetadata); fs.GetInformation(image, partition, null, out _, out FileSystem fsMetadata);
if(test.ApplicationId != null) if(test.ApplicationId != null)
{
Assert.AreEqual(test.ApplicationId, fsMetadata.ApplicationIdentifier, Assert.AreEqual(test.ApplicationId, fsMetadata.ApplicationIdentifier,
string.Format(Localization.Application_ID_0, testFile)); string.Format(Localization.Application_ID_0, testFile));
}
Assert.AreEqual(test.Bootable, fsMetadata.Bootable, string.Format(Localization.Bootable_0, testFile)); Assert.AreEqual(test.Bootable, fsMetadata.Bootable, string.Format(Localization.Bootable_0, testFile));
Assert.AreEqual(test.Clusters, fsMetadata.Clusters, string.Format(Localization.Clusters_0, testFile)); Assert.AreEqual(test.Clusters, fsMetadata.Clusters, string.Format(Localization.Clusters_0, testFile));
@@ -243,8 +245,10 @@ public abstract class FilesystemTest
string.Format(Localization.Cluster_size_0, testFile)); string.Format(Localization.Cluster_size_0, testFile));
if(test.SystemId != null) if(test.SystemId != null)
{
Assert.AreEqual(test.SystemId, fsMetadata.SystemIdentifier, Assert.AreEqual(test.SystemId, fsMetadata.SystemIdentifier,
string.Format(Localization.System_ID_0, testFile)); string.Format(Localization.System_ID_0, testFile));
}
Assert.AreEqual(_fileSystemType ?? test.Type, fsMetadata.Type, Assert.AreEqual(_fileSystemType ?? test.Type, fsMetadata.Type,
string.Format(Localization.Filesystem_type_0, testFile)); string.Format(Localization.Filesystem_type_0, testFile));

View File

@@ -41,6 +41,7 @@ public class Hpfs : FilesystemTest
public override string DataFolder => Path.Combine(Consts.TestFilesRoot, "Filesystems", public override string DataFolder => Path.Combine(Consts.TestFilesRoot, "Filesystems",
"High Performance File System"); "High Performance File System");
public override IFilesystem Plugin => new HPFS(); public override IFilesystem Plugin => new HPFS();
public override bool Partitions => true; public override bool Partitions => true;

View File

@@ -41,6 +41,7 @@ public class Hpofs : FilesystemTest
public override string DataFolder => Path.Combine(Consts.TestFilesRoot, "Filesystems", public override string DataFolder => Path.Combine(Consts.TestFilesRoot, "Filesystems",
"High Performance Optical File System"); "High Performance Optical File System");
public override IFilesystem Plugin => new HPOFS(); public override IFilesystem Plugin => new HPOFS();
public override bool Partitions => false; public override bool Partitions => false;

View File

@@ -41,6 +41,7 @@ public class MBR : FilesystemTest
public override string DataFolder => public override string DataFolder =>
Path.Combine(Consts.TestFilesRoot, "Filesystems", "High Throughput File System (MBR)"); Path.Combine(Consts.TestFilesRoot, "Filesystems", "High Throughput File System (MBR)");
public override IFilesystem Plugin => new SysVfs(); public override IFilesystem Plugin => new SysVfs();
public override bool Partitions => true; public override bool Partitions => true;

View File

@@ -41,6 +41,7 @@ public class Nilfs2 : FilesystemTest
public override string DataFolder => Path.Combine(Consts.TestFilesRoot, "Filesystems", public override string DataFolder => Path.Combine(Consts.TestFilesRoot, "Filesystems",
"New Implementation of a Log-structured File System 2"); "New Implementation of a Log-structured File System 2");
public override IFilesystem Plugin => new NILFS2(); public override IFilesystem Plugin => new NILFS2();
public override bool Partitions => true; public override bool Partitions => true;

View File

@@ -40,6 +40,7 @@ public class GPT : FilesystemTest
public override string DataFolder => public override string DataFolder =>
Path.Combine(Consts.TestFilesRoot, "Filesystems", "New Technology File System (GPT)"); Path.Combine(Consts.TestFilesRoot, "Filesystems", "New Technology File System (GPT)");
public override IFilesystem Plugin => new Aaru.Filesystems.NTFS(); public override IFilesystem Plugin => new Aaru.Filesystems.NTFS();
public override bool Partitions => true; public override bool Partitions => true;

View File

@@ -41,6 +41,7 @@ public class APM : FilesystemTest
public override string DataFolder => Path.Combine(Consts.TestFilesRoot, "Filesystems", public override string DataFolder => Path.Combine(Consts.TestFilesRoot, "Filesystems",
"Professional File System 3 (APM)"); "Professional File System 3 (APM)");
public override IFilesystem Plugin => new PFS(); public override IFilesystem Plugin => new PFS();
public override bool Partitions => true; public override bool Partitions => true;

View File

@@ -41,6 +41,7 @@ public class RDB : FilesystemTest
public override string DataFolder => Path.Combine(Consts.TestFilesRoot, "Filesystems", public override string DataFolder => Path.Combine(Consts.TestFilesRoot, "Filesystems",
"Professional File System 3 (RDB)"); "Professional File System 3 (RDB)");
public override IFilesystem Plugin => new PFS(); public override IFilesystem Plugin => new PFS();
public override bool Partitions => true; public override bool Partitions => true;

View File

@@ -41,6 +41,7 @@ public class ReFsMbr : FilesystemTest
public override string DataFolder => Path.Combine(Consts.TestFilesRoot, "Filesystems", public override string DataFolder => Path.Combine(Consts.TestFilesRoot, "Filesystems",
"Resilient File System (MBR)"); "Resilient File System (MBR)");
public override IFilesystem Plugin => new ReFS(); public override IFilesystem Plugin => new ReFS();
public override bool Partitions => true; public override bool Partitions => true;

View File

@@ -32,7 +32,7 @@ public abstract class ReadOnlyFilesystemTest : FilesystemTest
foreach(FileSystemTest test in Tests) foreach(FileSystemTest test in Tests)
{ {
string testFile = test.TestFile; string testFile = test.TestFile;
bool found = false; var found = false;
var partition = new Partition(); var partition = new Partition();
bool exists = File.Exists(testFile); bool exists = File.Exists(testFile);
@@ -128,8 +128,10 @@ public abstract class ReadOnlyFilesystemTest : FilesystemTest
}; };
if(test.ContentsJson != null) if(test.ContentsJson != null)
{
test.Contents = test.Contents =
JsonSerializer.Deserialize<Dictionary<string, FileData>>(test.ContentsJson, serializerOptions); JsonSerializer.Deserialize<Dictionary<string, FileData>>(test.ContentsJson, serializerOptions);
}
else if(File.Exists($"{testFile}.contents.json")) else if(File.Exists($"{testFile}.contents.json"))
{ {
var sr = new FileStream($"{testFile}.contents.json", FileMode.Open); var sr = new FileStream($"{testFile}.contents.json", FileMode.Open);
@@ -139,7 +141,7 @@ public abstract class ReadOnlyFilesystemTest : FilesystemTest
if(test.Contents is null) if(test.Contents is null)
continue; continue;
int currentDepth = 0; var currentDepth = 0;
TestDirectory(fs, "/", test.Contents, testFile, true, out List<NextLevel> currentLevel, currentDepth); TestDirectory(fs, "/", test.Contents, testFile, true, out List<NextLevel> currentLevel, currentDepth);
@@ -150,7 +152,7 @@ public abstract class ReadOnlyFilesystemTest : FilesystemTest
foreach(NextLevel subLevel in currentLevel) foreach(NextLevel subLevel in currentLevel)
{ {
TestDirectory(fs, subLevel.Path, subLevel.Children, testFile, true, TestDirectory(fs, subLevel.Path, subLevel.Children, testFile, true,
out List<NextLevel> nextLevel, currentDepth); out List<NextLevel> nextLevel, currentDepth);
nextLevels.AddRange(nextLevel); nextLevels.AddRange(nextLevel);
@@ -162,7 +164,8 @@ public abstract class ReadOnlyFilesystemTest : FilesystemTest
}); });
} }
[Test, Ignore("Not a test, do not run")] [Test]
[Ignore("Not a test, do not run")]
public void Build() public void Build()
{ {
Environment.CurrentDirectory = DataFolder; Environment.CurrentDirectory = DataFolder;
@@ -170,7 +173,7 @@ public abstract class ReadOnlyFilesystemTest : FilesystemTest
foreach(FileSystemTest test in Tests) foreach(FileSystemTest test in Tests)
{ {
string testFile = test.TestFile; string testFile = test.TestFile;
bool found = false; var found = false;
var partition = new Partition(); var partition = new Partition();
bool exists = File.Exists(testFile); bool exists = File.Exists(testFile);
@@ -275,7 +278,7 @@ public abstract class ReadOnlyFilesystemTest : FilesystemTest
while(fs.ReadDir(node, out string child) == ErrorNumber.NoError && while(fs.ReadDir(node, out string child) == ErrorNumber.NoError &&
child is not null) child is not null)
{ {
string childPath = $"{path}/{child}"; var childPath = $"{path}/{child}";
fs.Stat(childPath, out FileEntryInfo stat); fs.Stat(childPath, out FileEntryInfo stat);
var data = new FileData var data = new FileData
@@ -311,7 +314,7 @@ public abstract class ReadOnlyFilesystemTest : FilesystemTest
static string BuildFile(IReadOnlyFilesystem fs, string path, long length) static string BuildFile(IReadOnlyFilesystem fs, string path, long length)
{ {
byte[] buffer = new byte[length]; var buffer = new byte[length];
ErrorNumber error = fs.OpenFile(path, out IFileNode fileNode); ErrorNumber error = fs.OpenFile(path, out IFileNode fileNode);
@@ -340,7 +343,8 @@ public abstract class ReadOnlyFilesystemTest : FilesystemTest
string data; string data;
data = ret != ErrorNumber.NoError && ret != ErrorNumber.OutOfRange data = ret != ErrorNumber.NoError && ret != ErrorNumber.OutOfRange
? Md5Context.Data(Array.Empty<byte>(), out _) : Md5Context.Data(buffer, out _); ? Md5Context.Data(Array.Empty<byte>(), out _)
: Md5Context.Data(buffer, out _);
xattrs[xattr] = data; xattrs[xattr] = data;
} }
@@ -348,9 +352,9 @@ public abstract class ReadOnlyFilesystemTest : FilesystemTest
return xattrs; return xattrs;
} }
internal static void TestDirectory(IReadOnlyFilesystem fs, string path, Dictionary<string, FileData> children, internal static void TestDirectory(IReadOnlyFilesystem fs, string path, Dictionary<string, FileData> children,
string testFile, bool testXattr, out List<NextLevel> nextLevels, string testFile, bool testXattr, out List<NextLevel> nextLevels,
int currentDepth) int currentDepth)
{ {
currentDepth++; currentDepth++;
nextLevels = new List<NextLevel>(); nextLevels = new List<NextLevel>();
@@ -386,12 +390,12 @@ public abstract class ReadOnlyFilesystemTest : FilesystemTest
foreach(KeyValuePair<string, FileData> child in children) foreach(KeyValuePair<string, FileData> child in children)
{ {
string childPath = $"{path}/{child.Key}"; var childPath = $"{path}/{child.Key}";
ret = fs.Stat(childPath, out FileEntryInfo stat); ret = fs.Stat(childPath, out FileEntryInfo stat);
if(ret == ErrorNumber.NoSuchFile || if(ret == ErrorNumber.NoSuchFile ||
contents is null || contents is null ||
(ret == ErrorNumber.NoError && !contents.Contains(child.Key))) ret == ErrorNumber.NoError && !contents.Contains(child.Key))
{ {
expectedNotFound.Add(child.Key); expectedNotFound.Add(child.Key);
@@ -454,8 +458,9 @@ public abstract class ReadOnlyFilesystemTest : FilesystemTest
{ {
Assert.IsNotNull(child.Value.Children, Assert.IsNotNull(child.Value.Children,
string. string.
Format(Localization.Contents_for_0_in_1_must_be_defined_in_unit_test_declaration, Format(
childPath, testFile)); Localization.Contents_for_0_in_1_must_be_defined_in_unit_test_declaration,
childPath, testFile));
if(child.Value.Children != null) if(child.Value.Children != null)
{ {
@@ -491,8 +496,10 @@ public abstract class ReadOnlyFilesystemTest : FilesystemTest
{ {
Assert.IsNull(child.Value.XattrsWithMd5, Assert.IsNull(child.Value.XattrsWithMd5,
string. string.
Format(Localization.Defined_extended_attributes_for_0_in_1_are_not_supported_by_filesystem, Format(
childPath, testFile)); Localization.
Defined_extended_attributes_for_0_in_1_are_not_supported_by_filesystem,
childPath, testFile));
continue; continue;
} }
@@ -502,10 +509,14 @@ public abstract class ReadOnlyFilesystemTest : FilesystemTest
ret, childPath, testFile)); ret, childPath, testFile));
if(xattrs.Count > 0) if(xattrs.Count > 0)
{
Assert.IsNotNull(child.Value.XattrsWithMd5, Assert.IsNotNull(child.Value.XattrsWithMd5,
string. string.
Format(Localization.Extended_attributes_for_0_in_1_must_be_defined_in_unit_test_declaration, Format(
childPath, testFile)); Localization.
Extended_attributes_for_0_in_1_must_be_defined_in_unit_test_declaration,
childPath, testFile));
}
if(xattrs.Count > 0 || if(xattrs.Count > 0 ||
child.Value.XattrsWithMd5?.Count > 0) child.Value.XattrsWithMd5?.Count > 0)
@@ -517,14 +528,16 @@ public abstract class ReadOnlyFilesystemTest : FilesystemTest
string.Join(" ", expectedNotFound))); string.Join(" ", expectedNotFound)));
if(contents != null) if(contents != null)
{
Assert.IsEmpty(contents, Assert.IsEmpty(contents,
string.Format(Localization.Found_the_following_unexpected_children_of_0_in_1_2, path, string.Format(Localization.Found_the_following_unexpected_children_of_0_in_1_2, path,
testFile, string.Join(" ", contents))); testFile, string.Join(" ", contents)));
}
} }
static void TestFile(IReadOnlyFilesystem fs, string path, string md5, long length, string testFile) static void TestFile(IReadOnlyFilesystem fs, string path, string md5, long length, string testFile)
{ {
byte[] buffer = new byte[length]; var buffer = new byte[length];
ErrorNumber ret = fs.OpenFile(path, out IFileNode fileNode); ErrorNumber ret = fs.OpenFile(path, out IFileNode fileNode);
Assert.AreEqual(ErrorNumber.NoError, ret, Assert.AreEqual(ErrorNumber.NoError, ret,
@@ -578,9 +591,11 @@ public abstract class ReadOnlyFilesystemTest : FilesystemTest
// Partially read extended attribute... dunno why it happens with some Toast images // Partially read extended attribute... dunno why it happens with some Toast images
if(ret != ErrorNumber.OutOfRange) if(ret != ErrorNumber.OutOfRange)
{
Assert.AreEqual(ErrorNumber.NoError, ret, Assert.AreEqual(ErrorNumber.NoError, ret,
string.Format(Localization.Unexpected_error_0_retrieving_extended_attributes_for_1_in_2, string.Format(Localization.Unexpected_error_0_retrieving_extended_attributes_for_1_in_2,
ret, path, testFile)); ret, path, testFile));
}
string data = Md5Context.Data(buffer, out _); string data = Md5Context.Data(buffer, out _);
@@ -598,5 +613,9 @@ public abstract class ReadOnlyFilesystemTest : FilesystemTest
testFile, string.Join(" ", contents))); testFile, string.Join(" ", contents)));
} }
#region Nested type: NextLevel
internal sealed record NextLevel(string Path, Dictionary<string, FileData> Children); internal sealed record NextLevel(string Path, Dictionary<string, FileData> Children);
#endregion
} }

View File

@@ -34,13 +34,15 @@ using NUnit.Framework;
namespace Aaru.Tests.Filesystems.SFS; namespace Aaru.Tests.Filesystems.SFS;
[TestFixture, SuppressMessage("ReSharper", "InconsistentNaming")] [TestFixture]
[SuppressMessage("ReSharper", "InconsistentNaming")]
public class MBR_RDB : FilesystemTest public class MBR_RDB : FilesystemTest
{ {
public MBR_RDB() : base("sfs") {} public MBR_RDB() : base("sfs") {}
public override string DataFolder => public override string DataFolder =>
Path.Combine(Consts.TestFilesRoot, "Filesystems", "Smart File System (MBR+RDB)"); Path.Combine(Consts.TestFilesRoot, "Filesystems", "Smart File System (MBR+RDB)");
public override IFilesystem Plugin => new Aaru.Filesystems.SFS(); public override IFilesystem Plugin => new Aaru.Filesystems.SFS();
public override bool Partitions => true; public override bool Partitions => true;

View File

@@ -39,6 +39,7 @@ public class Whole : FilesystemTest
{ {
public override string DataFolder => public override string DataFolder =>
Path.Combine(Consts.TestFilesRoot, "Filesystems", "Universal Disc Format", "1.02"); Path.Combine(Consts.TestFilesRoot, "Filesystems", "Universal Disc Format", "1.02");
public override IFilesystem Plugin => new Aaru.Filesystems.UDF(); public override IFilesystem Plugin => new Aaru.Filesystems.UDF();
public override bool Partitions => false; public override bool Partitions => false;

View File

@@ -39,6 +39,7 @@ public class Optical : FilesystemTest
{ {
public override string DataFolder => public override string DataFolder =>
Path.Combine(Consts.TestFilesRoot, "Filesystems", "Universal Disc Format", "1.50"); Path.Combine(Consts.TestFilesRoot, "Filesystems", "Universal Disc Format", "1.50");
public override IFilesystem Plugin => new Aaru.Filesystems.UDF(); public override IFilesystem Plugin => new Aaru.Filesystems.UDF();
public override bool Partitions => false; public override bool Partitions => false;

View File

@@ -39,6 +39,7 @@ public class Whole : FilesystemTest
{ {
public override string DataFolder => public override string DataFolder =>
Path.Combine(Consts.TestFilesRoot, "Filesystems", "Universal Disc Format", "1.50"); Path.Combine(Consts.TestFilesRoot, "Filesystems", "Universal Disc Format", "1.50");
public override IFilesystem Plugin => new Aaru.Filesystems.UDF(); public override IFilesystem Plugin => new Aaru.Filesystems.UDF();
public override bool Partitions => false; public override bool Partitions => false;

View File

@@ -39,6 +39,7 @@ public class Optical : FilesystemTest
{ {
public override string DataFolder => public override string DataFolder =>
Path.Combine(Consts.TestFilesRoot, "Filesystems", "Universal Disc Format", "2.00"); Path.Combine(Consts.TestFilesRoot, "Filesystems", "Universal Disc Format", "2.00");
public override IFilesystem Plugin => new Aaru.Filesystems.UDF(); public override IFilesystem Plugin => new Aaru.Filesystems.UDF();
public override bool Partitions => false; public override bool Partitions => false;

View File

@@ -39,6 +39,7 @@ public class Whole : FilesystemTest
{ {
public override string DataFolder => public override string DataFolder =>
Path.Combine(Consts.TestFilesRoot, "Filesystems", "Universal Disc Format", "2.00"); Path.Combine(Consts.TestFilesRoot, "Filesystems", "Universal Disc Format", "2.00");
public override IFilesystem Plugin => new Aaru.Filesystems.UDF(); public override IFilesystem Plugin => new Aaru.Filesystems.UDF();
public override bool Partitions => false; public override bool Partitions => false;

View File

@@ -39,6 +39,7 @@ public class Optical : FilesystemTest
{ {
public override string DataFolder => public override string DataFolder =>
Path.Combine(Consts.TestFilesRoot, "Filesystems", "Universal Disc Format", "2.01"); Path.Combine(Consts.TestFilesRoot, "Filesystems", "Universal Disc Format", "2.01");
public override IFilesystem Plugin => new Aaru.Filesystems.UDF(); public override IFilesystem Plugin => new Aaru.Filesystems.UDF();
public override bool Partitions => false; public override bool Partitions => false;

View File

@@ -39,6 +39,7 @@ public class Whole : FilesystemTest
{ {
public override string DataFolder => public override string DataFolder =>
Path.Combine(Consts.TestFilesRoot, "Filesystems", "Universal Disc Format", "2.01"); Path.Combine(Consts.TestFilesRoot, "Filesystems", "Universal Disc Format", "2.01");
public override IFilesystem Plugin => new Aaru.Filesystems.UDF(); public override IFilesystem Plugin => new Aaru.Filesystems.UDF();
public override bool Partitions => false; public override bool Partitions => false;

View File

@@ -39,6 +39,7 @@ public class Whole : FilesystemTest
{ {
public override string DataFolder => public override string DataFolder =>
Path.Combine(Consts.TestFilesRoot, "Filesystems", "Universal Disc Format", "2.50"); Path.Combine(Consts.TestFilesRoot, "Filesystems", "Universal Disc Format", "2.50");
public override IFilesystem Plugin => new Aaru.Filesystems.UDF(); public override IFilesystem Plugin => new Aaru.Filesystems.UDF();
public override bool Partitions => false; public override bool Partitions => false;

View File

@@ -40,6 +40,7 @@ public class Whole : FilesystemTest
{ {
public override string DataFolder => public override string DataFolder =>
Path.Combine(Consts.TestFilesRoot, "Filesystems", "Universal Disc Format", "2.60"); Path.Combine(Consts.TestFilesRoot, "Filesystems", "Universal Disc Format", "2.60");
public override IFilesystem Plugin => new Aaru.Filesystems.UDF(); public override IFilesystem Plugin => new Aaru.Filesystems.UDF();
public override bool Partitions => false; public override bool Partitions => false;

View File

@@ -35,7 +35,8 @@ using NUnit.Framework;
namespace Aaru.Tests.Filesystems.UFS; namespace Aaru.Tests.Filesystems.UFS;
[TestFixture, SuppressMessage("ReSharper", "InconsistentNaming")] [TestFixture]
[SuppressMessage("ReSharper", "InconsistentNaming")]
public class NeXT_Floppy : FilesystemTest public class NeXT_Floppy : FilesystemTest
{ {
public override string DataFolder => Path.Combine(Consts.TestFilesRoot, "Filesystems", "UNIX filesystem (NeXT)"); public override string DataFolder => Path.Combine(Consts.TestFilesRoot, "Filesystems", "UNIX filesystem (NeXT)");

View File

@@ -35,11 +35,13 @@ using NUnit.Framework;
namespace Aaru.Tests.Filesystems.UFS; namespace Aaru.Tests.Filesystems.UFS;
[TestFixture, SuppressMessage("ReSharper", "InconsistentNaming")] [TestFixture]
[SuppressMessage("ReSharper", "InconsistentNaming")]
public class Sun_i86 : FilesystemTest public class Sun_i86 : FilesystemTest
{ {
public override string DataFolder => public override string DataFolder =>
Path.Combine(Consts.TestFilesRoot, "Filesystems", "UNIX filesystem (SunOS x86)"); Path.Combine(Consts.TestFilesRoot, "Filesystems", "UNIX filesystem (SunOS x86)");
public override IFilesystem Plugin => new FFSPlugin(); public override IFilesystem Plugin => new FFSPlugin();
public override bool Partitions => true; public override bool Partitions => true;

View File

@@ -39,6 +39,7 @@ public class Ext : FilesystemTest
{ {
public override string DataFolder => public override string DataFolder =>
Path.Combine(Consts.TestFilesRoot, "Filesystems", "Linux extended File System"); Path.Combine(Consts.TestFilesRoot, "Filesystems", "Linux extended File System");
public override IFilesystem Plugin => new extFS(); public override IFilesystem Plugin => new extFS();
public override bool Partitions => true; public override bool Partitions => true;

View File

@@ -59,7 +59,7 @@ public class AppleDoubleDave
IFilter filter = new AppleDouble(); IFilter filter = new AppleDouble();
filter.Open(_location); filter.Open(_location);
Stream str = filter.GetDataForkStream(); Stream str = filter.GetDataForkStream();
byte[] data = new byte[737280]; var data = new byte[737280];
str.EnsureRead(data, 0, 737280); str.EnsureRead(data, 0, 737280);
str.Close(); str.Close();
str.Dispose(); str.Dispose();
@@ -91,7 +91,7 @@ public class AppleDoubleDave
IFilter filter = new AppleDouble(); IFilter filter = new AppleDouble();
filter.Open(_location); filter.Open(_location);
Stream str = filter.GetResourceForkStream(); Stream str = filter.GetResourceForkStream();
byte[] data = new byte[286]; var data = new byte[286];
str.EnsureRead(data, 0, 286); str.EnsureRead(data, 0, 286);
str.Close(); str.Close();
str.Dispose(); str.Dispose();
@@ -105,7 +105,7 @@ public class AppleDoubleDave
{ {
IFilter filter = new AppleDouble(); IFilter filter = new AppleDouble();
Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location)); Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location));
Assert.AreEqual(737280, filter.DataForkLength); Assert.AreEqual(737280, filter.DataForkLength);
Assert.AreNotEqual(null, filter.GetDataForkStream()); Assert.AreNotEqual(null, filter.GetDataForkStream());
Assert.AreEqual(286, filter.ResourceForkLength); Assert.AreEqual(286, filter.ResourceForkLength);
Assert.AreNotEqual(null, filter.GetResourceForkStream()); Assert.AreNotEqual(null, filter.GetResourceForkStream());

View File

@@ -58,7 +58,7 @@ public class AppleDoubleDos
IFilter filter = new AppleDouble(); IFilter filter = new AppleDouble();
filter.Open(_location); filter.Open(_location);
Stream str = filter.GetDataForkStream(); Stream str = filter.GetDataForkStream();
byte[] data = new byte[737280]; var data = new byte[737280];
str.EnsureRead(data, 0, 737280); str.EnsureRead(data, 0, 737280);
str.Close(); str.Close();
str.Dispose(); str.Dispose();
@@ -90,7 +90,7 @@ public class AppleDoubleDos
IFilter filter = new AppleDouble(); IFilter filter = new AppleDouble();
filter.Open(_location); filter.Open(_location);
Stream str = filter.GetResourceForkStream(); Stream str = filter.GetResourceForkStream();
byte[] data = new byte[286]; var data = new byte[286];
str.EnsureRead(data, 0, 286); str.EnsureRead(data, 0, 286);
str.Close(); str.Close();
str.Dispose(); str.Dispose();
@@ -104,7 +104,7 @@ public class AppleDoubleDos
{ {
IFilter filter = new AppleDouble(); IFilter filter = new AppleDouble();
Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location)); Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location));
Assert.AreEqual(737280, filter.DataForkLength); Assert.AreEqual(737280, filter.DataForkLength);
Assert.AreNotEqual(null, filter.GetDataForkStream()); Assert.AreNotEqual(null, filter.GetDataForkStream());
Assert.AreEqual(286, filter.ResourceForkLength); Assert.AreEqual(286, filter.ResourceForkLength);
Assert.AreNotEqual(null, filter.GetResourceForkStream()); Assert.AreNotEqual(null, filter.GetResourceForkStream());

View File

@@ -60,7 +60,7 @@ public class AppleDoubleNetatalk
IFilter filter = new AppleDouble(); IFilter filter = new AppleDouble();
filter.Open(_location); filter.Open(_location);
Stream str = filter.GetDataForkStream(); Stream str = filter.GetDataForkStream();
byte[] data = new byte[737280]; var data = new byte[737280];
str.EnsureRead(data, 0, 737280); str.EnsureRead(data, 0, 737280);
str.Close(); str.Close();
str.Dispose(); str.Dispose();
@@ -92,7 +92,7 @@ public class AppleDoubleNetatalk
IFilter filter = new AppleDouble(); IFilter filter = new AppleDouble();
filter.Open(_location); filter.Open(_location);
Stream str = filter.GetResourceForkStream(); Stream str = filter.GetResourceForkStream();
byte[] data = new byte[286]; var data = new byte[286];
str.EnsureRead(data, 0, 286); str.EnsureRead(data, 0, 286);
str.Close(); str.Close();
str.Dispose(); str.Dispose();
@@ -106,7 +106,7 @@ public class AppleDoubleNetatalk
{ {
IFilter filter = new AppleDouble(); IFilter filter = new AppleDouble();
Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location)); Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location));
Assert.AreEqual(737280, filter.DataForkLength); Assert.AreEqual(737280, filter.DataForkLength);
Assert.AreNotEqual(null, filter.GetDataForkStream()); Assert.AreNotEqual(null, filter.GetDataForkStream());
Assert.AreEqual(286, filter.ResourceForkLength); Assert.AreEqual(286, filter.ResourceForkLength);
Assert.AreNotEqual(null, filter.GetResourceForkStream()); Assert.AreNotEqual(null, filter.GetResourceForkStream());

View File

@@ -58,7 +58,7 @@ public class AppleDoubleOsX
IFilter filter = new AppleDouble(); IFilter filter = new AppleDouble();
filter.Open(_location); filter.Open(_location);
Stream str = filter.GetDataForkStream(); Stream str = filter.GetDataForkStream();
byte[] data = new byte[737280]; var data = new byte[737280];
str.EnsureRead(data, 0, 737280); str.EnsureRead(data, 0, 737280);
str.Close(); str.Close();
str.Dispose(); str.Dispose();
@@ -90,7 +90,7 @@ public class AppleDoubleOsX
IFilter filter = new AppleDouble(); IFilter filter = new AppleDouble();
filter.Open(_location); filter.Open(_location);
Stream str = filter.GetResourceForkStream(); Stream str = filter.GetResourceForkStream();
byte[] data = new byte[286]; var data = new byte[286];
str.EnsureRead(data, 0, 286); str.EnsureRead(data, 0, 286);
str.Close(); str.Close();
str.Dispose(); str.Dispose();
@@ -104,7 +104,7 @@ public class AppleDoubleOsX
{ {
IFilter filter = new AppleDouble(); IFilter filter = new AppleDouble();
Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location)); Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location));
Assert.AreEqual(737280, filter.DataForkLength); Assert.AreEqual(737280, filter.DataForkLength);
Assert.AreNotEqual(null, filter.GetDataForkStream()); Assert.AreNotEqual(null, filter.GetDataForkStream());
Assert.AreEqual(286, filter.ResourceForkLength); Assert.AreEqual(286, filter.ResourceForkLength);
Assert.AreNotEqual(null, filter.GetResourceForkStream()); Assert.AreNotEqual(null, filter.GetResourceForkStream());

View File

@@ -58,7 +58,7 @@ public class AppleDoubleProDos
IFilter filter = new AppleDouble(); IFilter filter = new AppleDouble();
filter.Open(_location); filter.Open(_location);
Stream str = filter.GetDataForkStream(); Stream str = filter.GetDataForkStream();
byte[] data = new byte[737280]; var data = new byte[737280];
str.EnsureRead(data, 0, 737280); str.EnsureRead(data, 0, 737280);
str.Close(); str.Close();
str.Dispose(); str.Dispose();
@@ -90,7 +90,7 @@ public class AppleDoubleProDos
IFilter filter = new AppleDouble(); IFilter filter = new AppleDouble();
filter.Open(_location); filter.Open(_location);
Stream str = filter.GetResourceForkStream(); Stream str = filter.GetResourceForkStream();
byte[] data = new byte[286]; var data = new byte[286];
str.EnsureRead(data, 0, 286); str.EnsureRead(data, 0, 286);
str.Close(); str.Close();
str.Dispose(); str.Dispose();
@@ -104,7 +104,7 @@ public class AppleDoubleProDos
{ {
IFilter filter = new AppleDouble(); IFilter filter = new AppleDouble();
Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location)); Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location));
Assert.AreEqual(737280, filter.DataForkLength); Assert.AreEqual(737280, filter.DataForkLength);
Assert.AreNotEqual(null, filter.GetDataForkStream()); Assert.AreNotEqual(null, filter.GetDataForkStream());
Assert.AreEqual(286, filter.ResourceForkLength); Assert.AreEqual(286, filter.ResourceForkLength);
Assert.AreNotEqual(null, filter.GetResourceForkStream()); Assert.AreNotEqual(null, filter.GetResourceForkStream());

View File

@@ -58,7 +58,7 @@ public class AppleDoubleUnAr
IFilter filter = new AppleDouble(); IFilter filter = new AppleDouble();
filter.Open(_location); filter.Open(_location);
Stream str = filter.GetDataForkStream(); Stream str = filter.GetDataForkStream();
byte[] data = new byte[737280]; var data = new byte[737280];
str.EnsureRead(data, 0, 737280); str.EnsureRead(data, 0, 737280);
str.Close(); str.Close();
str.Dispose(); str.Dispose();
@@ -90,7 +90,7 @@ public class AppleDoubleUnAr
IFilter filter = new AppleDouble(); IFilter filter = new AppleDouble();
filter.Open(_location); filter.Open(_location);
Stream str = filter.GetResourceForkStream(); Stream str = filter.GetResourceForkStream();
byte[] data = new byte[286]; var data = new byte[286];
str.EnsureRead(data, 0, 286); str.EnsureRead(data, 0, 286);
str.Close(); str.Close();
str.Dispose(); str.Dispose();
@@ -104,7 +104,7 @@ public class AppleDoubleUnAr
{ {
IFilter filter = new AppleDouble(); IFilter filter = new AppleDouble();
Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location)); Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location));
Assert.AreEqual(737280, filter.DataForkLength); Assert.AreEqual(737280, filter.DataForkLength);
Assert.AreNotEqual(null, filter.GetDataForkStream()); Assert.AreNotEqual(null, filter.GetDataForkStream());
Assert.AreEqual(286, filter.ResourceForkLength); Assert.AreEqual(286, filter.ResourceForkLength);
Assert.AreNotEqual(null, filter.GetResourceForkStream()); Assert.AreNotEqual(null, filter.GetResourceForkStream());

View File

@@ -58,7 +58,7 @@ public class AppleDoubleUnix
IFilter filter = new AppleDouble(); IFilter filter = new AppleDouble();
filter.Open(_location); filter.Open(_location);
Stream str = filter.GetDataForkStream(); Stream str = filter.GetDataForkStream();
byte[] data = new byte[737280]; var data = new byte[737280];
str.EnsureRead(data, 0, 737280); str.EnsureRead(data, 0, 737280);
str.Close(); str.Close();
str.Dispose(); str.Dispose();
@@ -90,7 +90,7 @@ public class AppleDoubleUnix
IFilter filter = new AppleDouble(); IFilter filter = new AppleDouble();
filter.Open(_location); filter.Open(_location);
Stream str = filter.GetResourceForkStream(); Stream str = filter.GetResourceForkStream();
byte[] data = new byte[286]; var data = new byte[286];
str.EnsureRead(data, 0, 286); str.EnsureRead(data, 0, 286);
str.Close(); str.Close();
str.Dispose(); str.Dispose();
@@ -104,7 +104,7 @@ public class AppleDoubleUnix
{ {
IFilter filter = new AppleDouble(); IFilter filter = new AppleDouble();
Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location)); Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location));
Assert.AreEqual(737280, filter.DataForkLength); Assert.AreEqual(737280, filter.DataForkLength);
Assert.AreNotEqual(null, filter.GetDataForkStream()); Assert.AreNotEqual(null, filter.GetDataForkStream());
Assert.AreEqual(286, filter.ResourceForkLength); Assert.AreEqual(286, filter.ResourceForkLength);
Assert.AreNotEqual(null, filter.GetResourceForkStream()); Assert.AreNotEqual(null, filter.GetResourceForkStream());

View File

@@ -51,7 +51,7 @@ public class AppleSingle
IFilter filter = new Aaru.Filters.AppleSingle(); IFilter filter = new Aaru.Filters.AppleSingle();
filter.Open(_location); filter.Open(_location);
Stream str = filter.GetDataForkStream(); Stream str = filter.GetDataForkStream();
byte[] data = new byte[737280]; var data = new byte[737280];
str.EnsureRead(data, 0, 737280); str.EnsureRead(data, 0, 737280);
str.Close(); str.Close();
str.Dispose(); str.Dispose();
@@ -80,7 +80,7 @@ public class AppleSingle
IFilter filter = new Aaru.Filters.AppleSingle(); IFilter filter = new Aaru.Filters.AppleSingle();
filter.Open(_location); filter.Open(_location);
Stream str = filter.GetResourceForkStream(); Stream str = filter.GetResourceForkStream();
byte[] data = new byte[286]; var data = new byte[286];
str.EnsureRead(data, 0, 286); str.EnsureRead(data, 0, 286);
str.Close(); str.Close();
str.Dispose(); str.Dispose();
@@ -94,7 +94,7 @@ public class AppleSingle
{ {
IFilter filter = new Aaru.Filters.AppleSingle(); IFilter filter = new Aaru.Filters.AppleSingle();
Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location)); Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location));
Assert.AreEqual(737280, filter.DataForkLength); Assert.AreEqual(737280, filter.DataForkLength);
Assert.AreNotEqual(null, filter.GetDataForkStream()); Assert.AreNotEqual(null, filter.GetDataForkStream());
Assert.AreEqual(286, filter.ResourceForkLength); Assert.AreEqual(286, filter.ResourceForkLength);
Assert.AreNotEqual(null, filter.GetResourceForkStream()); Assert.AreNotEqual(null, filter.GetResourceForkStream());

View File

@@ -56,7 +56,7 @@ public class BZip2
IFilter filter = new Aaru.Filters.BZip2(); IFilter filter = new Aaru.Filters.BZip2();
filter.Open(_location); filter.Open(_location);
Stream str = filter.GetDataForkStream(); Stream str = filter.GetDataForkStream();
byte[] data = new byte[1048576]; var data = new byte[1048576];
str.EnsureRead(data, 0, 1048576); str.EnsureRead(data, 0, 1048576);
str.Close(); str.Close();
str.Dispose(); str.Dispose();
@@ -84,10 +84,10 @@ public class BZip2
{ {
IFilter filter = new Aaru.Filters.BZip2(); IFilter filter = new Aaru.Filters.BZip2();
Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location)); Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location));
Assert.AreEqual(1048576, filter.DataForkLength); Assert.AreEqual(1048576, filter.DataForkLength);
Assert.AreNotEqual(null, filter.GetDataForkStream()); Assert.AreNotEqual(null, filter.GetDataForkStream());
Assert.AreEqual(0, filter.ResourceForkLength); Assert.AreEqual(0, filter.ResourceForkLength);
Assert.AreEqual(null, filter.GetResourceForkStream()); Assert.AreEqual(null, filter.GetResourceForkStream());
Assert.AreEqual(false, filter.HasResourceFork); Assert.AreEqual(false, filter.HasResourceFork);
filter.Close(); filter.Close();
} }

View File

@@ -56,7 +56,7 @@ public class GZip
IFilter filter = new Aaru.Filters.GZip(); IFilter filter = new Aaru.Filters.GZip();
filter.Open(_location); filter.Open(_location);
Stream str = filter.GetDataForkStream(); Stream str = filter.GetDataForkStream();
byte[] data = new byte[1048576]; var data = new byte[1048576];
str.EnsureRead(data, 0, 1048576); str.EnsureRead(data, 0, 1048576);
str.Close(); str.Close();
str.Dispose(); str.Dispose();
@@ -84,10 +84,10 @@ public class GZip
{ {
IFilter filter = new Aaru.Filters.GZip(); IFilter filter = new Aaru.Filters.GZip();
Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location)); Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location));
Assert.AreEqual(1048576, filter.DataForkLength); Assert.AreEqual(1048576, filter.DataForkLength);
Assert.AreNotEqual(null, filter.GetDataForkStream()); Assert.AreNotEqual(null, filter.GetDataForkStream());
Assert.AreEqual(0, filter.ResourceForkLength); Assert.AreEqual(0, filter.ResourceForkLength);
Assert.AreEqual(null, filter.GetResourceForkStream()); Assert.AreEqual(null, filter.GetResourceForkStream());
Assert.AreEqual(false, filter.HasResourceFork); Assert.AreEqual(false, filter.HasResourceFork);
filter.Close(); filter.Close();
} }

View File

@@ -56,7 +56,7 @@ public class LZip
IFilter filter = new Aaru.Filters.LZip(); IFilter filter = new Aaru.Filters.LZip();
filter.Open(_location); filter.Open(_location);
Stream str = filter.GetDataForkStream(); Stream str = filter.GetDataForkStream();
byte[] data = new byte[1048576]; var data = new byte[1048576];
str.EnsureRead(data, 0, 1048576); str.EnsureRead(data, 0, 1048576);
str.Close(); str.Close();
str.Dispose(); str.Dispose();
@@ -84,10 +84,10 @@ public class LZip
{ {
IFilter filter = new Aaru.Filters.LZip(); IFilter filter = new Aaru.Filters.LZip();
Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location)); Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location));
Assert.AreEqual(1048576, filter.DataForkLength); Assert.AreEqual(1048576, filter.DataForkLength);
Assert.AreNotEqual(null, filter.GetDataForkStream()); Assert.AreNotEqual(null, filter.GetDataForkStream());
Assert.AreEqual(0, filter.ResourceForkLength); Assert.AreEqual(0, filter.ResourceForkLength);
Assert.AreEqual(null, filter.GetResourceForkStream()); Assert.AreEqual(null, filter.GetResourceForkStream());
Assert.AreEqual(false, filter.HasResourceFork); Assert.AreEqual(false, filter.HasResourceFork);
filter.Close(); filter.Close();
} }

View File

@@ -52,7 +52,7 @@ public class MacBinary1
IFilter filter = new MacBinary(); IFilter filter = new MacBinary();
filter.Open(_location); filter.Open(_location);
Stream str = filter.GetDataForkStream(); Stream str = filter.GetDataForkStream();
byte[] data = new byte[737280]; var data = new byte[737280];
str.EnsureRead(data, 0, 737280); str.EnsureRead(data, 0, 737280);
str.Close(); str.Close();
str.Dispose(); str.Dispose();
@@ -81,7 +81,7 @@ public class MacBinary1
IFilter filter = new MacBinary(); IFilter filter = new MacBinary();
filter.Open(_location); filter.Open(_location);
Stream str = filter.GetResourceForkStream(); Stream str = filter.GetResourceForkStream();
byte[] data = new byte[286]; var data = new byte[286];
str.EnsureRead(data, 0, 286); str.EnsureRead(data, 0, 286);
str.Close(); str.Close();
str.Dispose(); str.Dispose();
@@ -95,7 +95,7 @@ public class MacBinary1
{ {
IFilter filter = new MacBinary(); IFilter filter = new MacBinary();
Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location)); Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location));
Assert.AreEqual(737280, filter.DataForkLength); Assert.AreEqual(737280, filter.DataForkLength);
Assert.AreNotEqual(null, filter.GetDataForkStream()); Assert.AreNotEqual(null, filter.GetDataForkStream());
Assert.AreEqual(286, filter.ResourceForkLength); Assert.AreEqual(286, filter.ResourceForkLength);
Assert.AreNotEqual(null, filter.GetResourceForkStream()); Assert.AreNotEqual(null, filter.GetResourceForkStream());

View File

@@ -52,7 +52,7 @@ public class MacBinary2
IFilter filter = new MacBinary(); IFilter filter = new MacBinary();
filter.Open(_location); filter.Open(_location);
Stream str = filter.GetDataForkStream(); Stream str = filter.GetDataForkStream();
byte[] data = new byte[737280]; var data = new byte[737280];
str.EnsureRead(data, 0, 737280); str.EnsureRead(data, 0, 737280);
str.Close(); str.Close();
str.Dispose(); str.Dispose();
@@ -81,7 +81,7 @@ public class MacBinary2
IFilter filter = new MacBinary(); IFilter filter = new MacBinary();
filter.Open(_location); filter.Open(_location);
Stream str = filter.GetResourceForkStream(); Stream str = filter.GetResourceForkStream();
byte[] data = new byte[286]; var data = new byte[286];
str.EnsureRead(data, 0, 286); str.EnsureRead(data, 0, 286);
str.Close(); str.Close();
str.Dispose(); str.Dispose();
@@ -95,7 +95,7 @@ public class MacBinary2
{ {
IFilter filter = new MacBinary(); IFilter filter = new MacBinary();
Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location)); Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location));
Assert.AreEqual(737280, filter.DataForkLength); Assert.AreEqual(737280, filter.DataForkLength);
Assert.AreNotEqual(null, filter.GetDataForkStream()); Assert.AreNotEqual(null, filter.GetDataForkStream());
Assert.AreEqual(286, filter.ResourceForkLength); Assert.AreEqual(286, filter.ResourceForkLength);
Assert.AreNotEqual(null, filter.GetResourceForkStream()); Assert.AreNotEqual(null, filter.GetResourceForkStream());

View File

@@ -52,7 +52,7 @@ public class MacBinary3
IFilter filter = new MacBinary(); IFilter filter = new MacBinary();
filter.Open(_location); filter.Open(_location);
Stream str = filter.GetDataForkStream(); Stream str = filter.GetDataForkStream();
byte[] data = new byte[737280]; var data = new byte[737280];
str.EnsureRead(data, 0, 737280); str.EnsureRead(data, 0, 737280);
str.Close(); str.Close();
str.Dispose(); str.Dispose();
@@ -81,7 +81,7 @@ public class MacBinary3
IFilter filter = new MacBinary(); IFilter filter = new MacBinary();
filter.Open(_location); filter.Open(_location);
Stream str = filter.GetResourceForkStream(); Stream str = filter.GetResourceForkStream();
byte[] data = new byte[286]; var data = new byte[286];
str.EnsureRead(data, 0, 286); str.EnsureRead(data, 0, 286);
str.Close(); str.Close();
str.Dispose(); str.Dispose();
@@ -95,7 +95,7 @@ public class MacBinary3
{ {
IFilter filter = new MacBinary(); IFilter filter = new MacBinary();
Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location)); Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location));
Assert.AreEqual(737280, filter.DataForkLength); Assert.AreEqual(737280, filter.DataForkLength);
Assert.AreNotEqual(null, filter.GetDataForkStream()); Assert.AreNotEqual(null, filter.GetDataForkStream());
Assert.AreEqual(286, filter.ResourceForkLength); Assert.AreEqual(286, filter.ResourceForkLength);
Assert.AreNotEqual(null, filter.GetResourceForkStream()); Assert.AreNotEqual(null, filter.GetResourceForkStream());

View File

@@ -52,7 +52,7 @@ public class PcExchange
IFilter filter = new Aaru.Filters.PcExchange(); IFilter filter = new Aaru.Filters.PcExchange();
filter.Open(_location); filter.Open(_location);
Stream str = filter.GetDataForkStream(); Stream str = filter.GetDataForkStream();
byte[] data = new byte[737280]; var data = new byte[737280];
str.EnsureRead(data, 0, 737280); str.EnsureRead(data, 0, 737280);
str.Close(); str.Close();
str.Dispose(); str.Dispose();
@@ -83,7 +83,7 @@ public class PcExchange
IFilter filter = new Aaru.Filters.PcExchange(); IFilter filter = new Aaru.Filters.PcExchange();
filter.Open(_location); filter.Open(_location);
Stream str = filter.GetResourceForkStream(); Stream str = filter.GetResourceForkStream();
byte[] data = new byte[546]; var data = new byte[546];
str.EnsureRead(data, 0, 546); str.EnsureRead(data, 0, 546);
str.Close(); str.Close();
str.Dispose(); str.Dispose();
@@ -97,7 +97,7 @@ public class PcExchange
{ {
IFilter filter = new Aaru.Filters.PcExchange(); IFilter filter = new Aaru.Filters.PcExchange();
Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location)); Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location));
Assert.AreEqual(737280, filter.DataForkLength); Assert.AreEqual(737280, filter.DataForkLength);
Assert.AreNotEqual(null, filter.GetDataForkStream()); Assert.AreNotEqual(null, filter.GetDataForkStream());
Assert.AreEqual(546, filter.ResourceForkLength); Assert.AreEqual(546, filter.ResourceForkLength);
Assert.AreNotEqual(null, filter.GetResourceForkStream()); Assert.AreNotEqual(null, filter.GetResourceForkStream());

View File

@@ -57,7 +57,7 @@ public class Xz
IFilter filter = new XZ(); IFilter filter = new XZ();
filter.Open(_location); filter.Open(_location);
Stream str = filter.GetDataForkStream(); Stream str = filter.GetDataForkStream();
byte[] data = new byte[1048576]; var data = new byte[1048576];
str.EnsureRead(data, 0, 1048576); str.EnsureRead(data, 0, 1048576);
str.Close(); str.Close();
str.Dispose(); str.Dispose();
@@ -85,10 +85,10 @@ public class Xz
{ {
IFilter filter = new XZ(); IFilter filter = new XZ();
Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location)); Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location));
Assert.AreEqual(1048576, filter.DataForkLength); Assert.AreEqual(1048576, filter.DataForkLength);
Assert.AreNotEqual(null, filter.GetDataForkStream()); Assert.AreNotEqual(null, filter.GetDataForkStream());
Assert.AreEqual(0, filter.ResourceForkLength); Assert.AreEqual(0, filter.ResourceForkLength);
Assert.AreEqual(null, filter.GetResourceForkStream()); Assert.AreEqual(null, filter.GetResourceForkStream());
Assert.AreEqual(false, filter.HasResourceFork); Assert.AreEqual(false, filter.HasResourceFork);
filter.Close(); filter.Close();
} }

View File

@@ -16,30 +16,20 @@ public class Marshal
{ {
0x27, 0x50, 0x48, 0x53, 0x44, 0x31, 0x36, 0x47, 0x60, 0x01, 0x1a, 0x77, 0xd2, 0x01, 0x47, 0x01 0x27, 0x50, 0x48, 0x53, 0x44, 0x31, 0x36, 0x47, 0x60, 0x01, 0x1a, 0x77, 0xd2, 0x01, 0x47, 0x01
}, },
new byte[] new byte[] { 0x02, 0x35, 0x80, 0x00, 0x01, 0x00, 0x00, 0x00 }, new byte[] { 0xba, 0xbe, 0xfa, 0xce },
{ new byte[] { 0xce, 0xfa, 0xad, 0xde }
0x02, 0x35, 0x80, 0x00, 0x01, 0x00, 0x00, 0x00
},
new byte[]
{
0xba, 0xbe, 0xfa, 0xce
},
new byte[]
{
0xce, 0xfa, 0xad, 0xde
}
}; };
[Test] [Test]
public void ConvertFromHexAscii() public void ConvertFromHexAscii()
{ {
for(int i = 0; i < _testStrings.Length; i++) for(var i = 0; i < _testStrings.Length; i++)
{ {
int count = Aaru.Helpers.Marshal.ConvertFromHexAscii(_testStrings[i], out byte[] buf); int count = Aaru.Helpers.Marshal.ConvertFromHexAscii(_testStrings[i], out byte[] buf);
Assert.AreEqual(_resultBytes[i].Length, buf.Length); Assert.AreEqual(_resultBytes[i].Length, buf.Length);
Assert.AreEqual(_resultBytes[i].Length, count); Assert.AreEqual(_resultBytes[i].Length, count);
Assert.AreEqual(_resultBytes[i], buf); Assert.AreEqual(_resultBytes[i], buf);
} }
} }
} }

View File

@@ -1837,7 +1837,9 @@ public class Alcohol120 : OpticalMediaImageTest
} }
} }
}, },
#region These test images violate the specifications and are not expected to work yet
#region These test images violate the specifications and are not expected to work yet
/* /*
new OpticalImageTestExpected new OpticalImageTestExpected
{ {
@@ -2239,6 +2241,7 @@ public class Alcohol120 : OpticalMediaImageTest
} }
} }
},*/ },*/
#endregion
#endregion
}; };
} }

View File

@@ -39,6 +39,7 @@ public class DOS32 : BlockMediaImageTest
{ {
public override string DataFolder => public override string DataFolder =>
Path.Combine(Consts.TestFilesRoot, "Media image formats", "Apple DOS 13 sectors"); Path.Combine(Consts.TestFilesRoot, "Media image formats", "Apple DOS 13 sectors");
public override IMediaImage Plugin => new AppleDos(); public override IMediaImage Plugin => new AppleDos();
public override BlockImageTestExpected[] Tests => new[] public override BlockImageTestExpected[] Tests => new[]

View File

@@ -39,6 +39,7 @@ public class ProDOS : BlockMediaImageTest
{ {
public override string DataFolder => public override string DataFolder =>
Path.Combine(Consts.TestFilesRoot, "Media image formats", "Apple ProDOS Order"); Path.Combine(Consts.TestFilesRoot, "Media image formats", "Apple ProDOS Order");
public override IMediaImage Plugin => new AppleDos(); public override IMediaImage Plugin => new AppleDos();
public override BlockImageTestExpected[] Tests => new[] public override BlockImageTestExpected[] Tests => new[]

View File

@@ -1144,7 +1144,9 @@ public class BlindWrite4 : OpticalMediaImageTest
} }
} }
}, },
#region These test images violate the specifications and are not expected to work yet
#region These test images violate the specifications and are not expected to work yet
/* /*
new OpticalImageTestExpected new OpticalImageTestExpected
{ {
@@ -1395,6 +1397,7 @@ public class BlindWrite4 : OpticalMediaImageTest
} }
}, },
*/ */
#endregion
#endregion
}; };
} }

View File

@@ -1062,7 +1062,9 @@ public class BlindWrite5 : OpticalMediaImageTest
} }
} }
}, },
#region These test images violate the specifications and are not expected to work yet
#region These test images violate the specifications and are not expected to work yet
/* /*
new OpticalImageTestExpected new OpticalImageTestExpected
{ {
@@ -1361,6 +1363,7 @@ public class BlindWrite5 : OpticalMediaImageTest
} }
}, },
*/ */
#endregion
#endregion
}; };
} }

View File

@@ -53,6 +53,7 @@ public abstract class BlockMediaImageTest : BaseMediaImageTest
continue; continue;
using(new AssertionScope()) using(new AssertionScope())
{
Assert.Multiple(() => Assert.Multiple(() =>
{ {
Assert.AreEqual(test.Sectors, image.Info.Sectors, Assert.AreEqual(test.Sectors, image.Info.Sectors,
@@ -64,6 +65,7 @@ public abstract class BlockMediaImageTest : BaseMediaImageTest
Assert.AreEqual(test.MediaType, image.Info.MediaType, Assert.AreEqual(test.MediaType, image.Info.MediaType,
string.Format(Localization.Media_type_0, testFile)); string.Format(Localization.Media_type_0, testFile));
}); });
}
} }
}); });
} }
@@ -168,6 +170,7 @@ public abstract class BlockMediaImageTest : BaseMediaImageTest
List<Partition> partitions = Core.Partitions.GetAll(image); List<Partition> partitions = Core.Partitions.GetAll(image);
if(partitions.Count == 0) if(partitions.Count == 0)
{
partitions.Add(new Partition partitions.Add(new Partition
{ {
Description = "Whole device", Description = "Whole device",
@@ -177,30 +180,36 @@ public abstract class BlockMediaImageTest : BaseMediaImageTest
Sequence = 1, Sequence = 1,
Start = 0 Start = 0
}); });
}
Assert.AreEqual(test.Partitions.Length, partitions.Count, Assert.AreEqual(test.Partitions.Length, partitions.Count,
string.Format(Localization.Expected_0_partitions_in_1_but_found_2, string.Format(Localization.Expected_0_partitions_in_1_but_found_2,
test.Partitions.Length, testFile, partitions.Count)); test.Partitions.Length, testFile, partitions.Count));
using(new AssertionScope()) using(new AssertionScope())
{
Assert.Multiple(() => Assert.Multiple(() =>
{ {
for(int i = 0; i < test.Partitions.Length; i++) for(var i = 0; i < test.Partitions.Length; i++)
{ {
BlockPartitionVolumes expectedPartition = test.Partitions[i]; BlockPartitionVolumes expectedPartition = test.Partitions[i];
Partition foundPartition = partitions[i]; Partition foundPartition = partitions[i];
Assert.AreEqual(expectedPartition.Start, foundPartition.Start, Assert.AreEqual(expectedPartition.Start, foundPartition.Start,
string. string.
Format(Localization.Expected_partition_0_to_start_at_sector_1_but_found_it_starts_at_2_in_3, Format(
i, expectedPartition.Start, foundPartition.Start, testFile)); Localization.
Expected_partition_0_to_start_at_sector_1_but_found_it_starts_at_2_in_3,
i, expectedPartition.Start, foundPartition.Start, testFile));
Assert.AreEqual(expectedPartition.Length, foundPartition.Length, Assert.AreEqual(expectedPartition.Length, foundPartition.Length,
string. string.
Format(Localization.Expected_partition_0_to_have_1_sectors_but_found_it_has_2_sectors_in_3, Format(
i, expectedPartition.Length, foundPartition.Length, testFile)); Localization.
Expected_partition_0_to_have_1_sectors_but_found_it_has_2_sectors_in_3,
i, expectedPartition.Length, foundPartition.Length, testFile));
string expectedDataFilename = $"{testFile}.contents.partition{i}.json"; var expectedDataFilename = $"{testFile}.contents.partition{i}.json";
if(!File.Exists(expectedDataFilename)) if(!File.Exists(expectedDataFilename))
continue; continue;
@@ -273,7 +282,7 @@ public abstract class BlockMediaImageTest : BaseMediaImageTest
$"Expected {expectedData.Length} filesystems identified in partition {i $"Expected {expectedData.Length} filesystems identified in partition {i
} but found {idPlugins.Count} in {testFile}"); } but found {idPlugins.Count} in {testFile}");
for(int j = 0; j < idPlugins.Count; j++) for(var j = 0; j < idPlugins.Count; j++)
{ {
string pluginName = idPlugins[j]; string pluginName = idPlugins[j];
@@ -296,7 +305,7 @@ public abstract class BlockMediaImageTest : BaseMediaImageTest
VolumeData volumeData = expectedData[j]; VolumeData volumeData = expectedData[j];
int currentDepth = 0; var currentDepth = 0;
ReadOnlyFilesystemTest.TestDirectory(fs, "/", volumeData.Files, testFile, true, ReadOnlyFilesystemTest.TestDirectory(fs, "/", volumeData.Files, testFile, true,
out List<ReadOnlyFilesystemTest.NextLevel> out List<ReadOnlyFilesystemTest.NextLevel>
@@ -322,6 +331,7 @@ public abstract class BlockMediaImageTest : BaseMediaImageTest
} }
} }
}); });
}
} }
}); });
} }

View File

@@ -35,7 +35,8 @@ using NUnit.Framework;
namespace Aaru.Tests.Images; namespace Aaru.Tests.Images;
[TestFixture, SuppressMessage("ReSharper", "InconsistentNaming")] [TestFixture]
[SuppressMessage("ReSharper", "InconsistentNaming")]
public class CDRWin : OpticalMediaImageTest public class CDRWin : OpticalMediaImageTest
{ {
public override string DataFolder => Path.Combine(Consts.TestFilesRoot, "Media image formats", "CDRWin"); public override string DataFolder => Path.Combine(Consts.TestFilesRoot, "Media image formats", "CDRWin");

View File

@@ -34,7 +34,8 @@ using NUnit.Framework;
namespace Aaru.Tests.Images; namespace Aaru.Tests.Images;
[TestFixture, SuppressMessage("ReSharper", "InconsistentNaming")] [TestFixture]
[SuppressMessage("ReSharper", "InconsistentNaming")]
public class CDRWin10 : OpticalMediaImageTest public class CDRWin10 : OpticalMediaImageTest
{ {
public override string DataFolder => Path.Combine(Consts.TestFilesRoot, "Media image formats", "CDRWin 10"); public override string DataFolder => Path.Combine(Consts.TestFilesRoot, "Media image formats", "CDRWin 10");

View File

@@ -35,7 +35,8 @@ using NUnit.Framework;
namespace Aaru.Tests.Images; namespace Aaru.Tests.Images;
[TestFixture, SuppressMessage("ReSharper", "InconsistentNaming")] [TestFixture]
[SuppressMessage("ReSharper", "InconsistentNaming")]
public class CPCDSK : BlockMediaImageTest public class CPCDSK : BlockMediaImageTest
{ {
public override string DataFolder => Path.Combine(Consts.TestFilesRoot, "Media image formats", "CPCDSK"); public override string DataFolder => Path.Combine(Consts.TestFilesRoot, "Media image formats", "CPCDSK");

View File

@@ -35,7 +35,8 @@ using NUnit.Framework;
namespace Aaru.Tests.Images; namespace Aaru.Tests.Images;
[TestFixture, SuppressMessage("ReSharper", "InconsistentNaming")] [TestFixture]
[SuppressMessage("ReSharper", "InconsistentNaming")]
public class CloneCD : OpticalMediaImageTest public class CloneCD : OpticalMediaImageTest
{ {
public override string DataFolder => Path.Combine(Consts.TestFilesRoot, "Media image formats", "CloneCD"); public override string DataFolder => Path.Combine(Consts.TestFilesRoot, "Media image formats", "CloneCD");
@@ -1427,7 +1428,9 @@ public class CloneCD : OpticalMediaImageTest
} }
} }
}, },
#region These test images violate the specifications and are not expected to work yet
#region These test images violate the specifications and are not expected to work yet
/* /*
new OpticalImageTestExpected new OpticalImageTestExpected
{ {
@@ -1846,6 +1849,7 @@ public class CloneCD : OpticalMediaImageTest
} }
}, },
*/ */
#endregion
#endregion
}; };
} }

View File

@@ -38,6 +38,7 @@ public class D88 : BlockMediaImageTest
{ {
public override string DataFolder => Path.Combine(Consts.TestFilesRoot, "Media image formats", "D88"); public override string DataFolder => Path.Combine(Consts.TestFilesRoot, "Media image formats", "D88");
public override IMediaImage Plugin => new DiscImages.D88(); public override IMediaImage Plugin => new DiscImages.D88();
public override BlockImageTestExpected[] Tests => new[] public override BlockImageTestExpected[] Tests => new[]
{ {
new BlockImageTestExpected new BlockImageTestExpected

View File

@@ -73,7 +73,9 @@ public class Dart : BlockMediaImageTest
SectorSize = 512, SectorSize = 512,
Md5 = "93e71b9ecdb39d3ec9245b4f451856d4" Md5 = "93e71b9ecdb39d3ec9245b4f451856d4"
} }
#region Unsupported LZH compression
#region Unsupported LZH compression
/* /*
new BlockImageTestExpected new BlockImageTestExpected
{ {
@@ -108,6 +110,7 @@ public class Dart : BlockMediaImageTest
MD5 = "93e71b9ecdb39d3ec9245b4f451856d4" MD5 = "93e71b9ecdb39d3ec9245b4f451856d4"
}, },
*/ */
#endregion Unsupported LZH compression
#endregion Unsupported LZH compression
}; };
} }

View File

@@ -38,6 +38,7 @@ public class DiscJuggler : OpticalMediaImageTest
{ {
public override string DataFolder => Path.Combine(Consts.TestFilesRoot, "Media image formats", "DiscJuggler"); public override string DataFolder => Path.Combine(Consts.TestFilesRoot, "Media image formats", "DiscJuggler");
public override IMediaImage Plugin => new DiscImages.DiscJuggler(); public override IMediaImage Plugin => new DiscImages.DiscJuggler();
public override OpticalImageTestExpected[] Tests => new[] public override OpticalImageTestExpected[] Tests => new[]
{ {
new OpticalImageTestExpected new OpticalImageTestExpected
@@ -1959,7 +1960,9 @@ public class DiscJuggler : OpticalMediaImageTest
} }
} }
}, },
#region These test images violate the specifications and are not expected to work yet
#region These test images violate the specifications and are not expected to work yet
/* /*
new OpticalImageTestExpected new OpticalImageTestExpected
{ {
@@ -2106,6 +2109,7 @@ public class DiscJuggler : OpticalMediaImageTest
} }
}, },
*/ */
#endregion
#endregion
}; };
} }

View File

@@ -38,6 +38,7 @@ public class DiskCopy42 : BlockMediaImageTest
{ {
public override string DataFolder => Path.Combine(Consts.TestFilesRoot, "Media image formats", "DiskCopy 4.2"); public override string DataFolder => Path.Combine(Consts.TestFilesRoot, "Media image formats", "DiskCopy 4.2");
public override IMediaImage Plugin => new DiscImages.DiskCopy42(); public override IMediaImage Plugin => new DiscImages.DiskCopy42();
public override BlockImageTestExpected[] Tests => new[] public override BlockImageTestExpected[] Tests => new[]
{ {
new BlockImageTestExpected new BlockImageTestExpected

View File

@@ -38,6 +38,7 @@ public class DiskCopy42 : BlockMediaImageTest
{ {
public override string DataFolder => public override string DataFolder =>
Path.Combine(Consts.TestFilesRoot, "Media image formats", "DiskCopy 6.3.3", "DiskCopy 4.2"); Path.Combine(Consts.TestFilesRoot, "Media image formats", "DiskCopy 6.3.3", "DiskCopy 4.2");
public override IMediaImage Plugin => new DiscImages.DiskCopy42(); public override IMediaImage Plugin => new DiscImages.DiskCopy42();
public override BlockImageTestExpected[] Tests => new[] public override BlockImageTestExpected[] Tests => new[]

View File

@@ -35,11 +35,13 @@ using NUnit.Framework;
namespace Aaru.Tests.Images.DiskCopy633.NDIF; namespace Aaru.Tests.Images.DiskCopy633.NDIF;
[TestFixture, SuppressMessage("ReSharper", "InconsistentNaming")] [TestFixture]
[SuppressMessage("ReSharper", "InconsistentNaming")]
public class ROCo : BlockMediaImageTest public class ROCo : BlockMediaImageTest
{ {
public override string DataFolder => public override string DataFolder =>
Path.Combine(Consts.TestFilesRoot, "Media image formats", "DiskCopy 6.3.3", "NDIF", "ROCo"); Path.Combine(Consts.TestFilesRoot, "Media image formats", "DiskCopy 6.3.3", "NDIF", "ROCo");
public override IMediaImage Plugin => new Ndif(); public override IMediaImage Plugin => new Ndif();
public override BlockImageTestExpected[] Tests => new[] public override BlockImageTestExpected[] Tests => new[]

View File

@@ -39,6 +39,7 @@ public class RdWr : BlockMediaImageTest
{ {
public override string DataFolder => public override string DataFolder =>
Path.Combine(Consts.TestFilesRoot, "Media image formats", "DiskCopy 6.3.3", "NDIF", "RdWr"); Path.Combine(Consts.TestFilesRoot, "Media image formats", "DiskCopy 6.3.3", "NDIF", "RdWr");
public override IMediaImage Plugin => new Ndif(); public override IMediaImage Plugin => new Ndif();
public override BlockImageTestExpected[] Tests => new[] public override BlockImageTestExpected[] Tests => new[]

View File

@@ -39,6 +39,7 @@ public class Rdxx : BlockMediaImageTest
{ {
public override string DataFolder => public override string DataFolder =>
Path.Combine(Consts.TestFilesRoot, "Media image formats", "DiskCopy 6.3.3", "NDIF", "Rdxx"); Path.Combine(Consts.TestFilesRoot, "Media image formats", "DiskCopy 6.3.3", "NDIF", "Rdxx");
public override IMediaImage Plugin => new Ndif(); public override IMediaImage Plugin => new Ndif();
public override BlockImageTestExpected[] Tests => new[] public override BlockImageTestExpected[] Tests => new[]

View File

@@ -35,11 +35,13 @@ using NUnit.Framework;
namespace Aaru.Tests.Images.DiskCopy65; namespace Aaru.Tests.Images.DiskCopy65;
[TestFixture, SuppressMessage("ReSharper", "InconsistentNaming")] [TestFixture]
[SuppressMessage("ReSharper", "InconsistentNaming")]
public class UDCO : BlockMediaImageTest public class UDCO : BlockMediaImageTest
{ {
public override string DataFolder => public override string DataFolder =>
Path.Combine(Consts.TestFilesRoot, "Media image formats", "DiskCopy 6.5", "UDIF", "UDCO"); Path.Combine(Consts.TestFilesRoot, "Media image formats", "DiskCopy 6.5", "UDIF", "UDCO");
public override IMediaImage Plugin => new Udif(); public override IMediaImage Plugin => new Udif();
public override BlockImageTestExpected[] Tests => new[] public override BlockImageTestExpected[] Tests => new[]

View File

@@ -35,11 +35,13 @@ using NUnit.Framework;
namespace Aaru.Tests.Images.DiskCopy65; namespace Aaru.Tests.Images.DiskCopy65;
[TestFixture, SuppressMessage("ReSharper", "InconsistentNaming")] [TestFixture]
[SuppressMessage("ReSharper", "InconsistentNaming")]
public class UDCo_obsolete : BlockMediaImageTest public class UDCo_obsolete : BlockMediaImageTest
{ {
public override string DataFolder => public override string DataFolder =>
Path.Combine(Consts.TestFilesRoot, "Media image formats", "DiskCopy 6.5", "UDIF", "UDCo_OBS"); Path.Combine(Consts.TestFilesRoot, "Media image formats", "DiskCopy 6.5", "UDIF", "UDCo_OBS");
public override IMediaImage Plugin => new Udif(); public override IMediaImage Plugin => new Udif();
public override BlockImageTestExpected[] Tests => new[] public override BlockImageTestExpected[] Tests => new[]

View File

@@ -35,11 +35,13 @@ using NUnit.Framework;
namespace Aaru.Tests.Images.DiskCopy65; namespace Aaru.Tests.Images.DiskCopy65;
[TestFixture, SuppressMessage("ReSharper", "InconsistentNaming")] [TestFixture]
[SuppressMessage("ReSharper", "InconsistentNaming")]
public class UDRAW : BlockMediaImageTest public class UDRAW : BlockMediaImageTest
{ {
public override string DataFolder => public override string DataFolder =>
Path.Combine(Consts.TestFilesRoot, "Media image formats", "DiskCopy 6.5", "UDIF", "UDRAW"); Path.Combine(Consts.TestFilesRoot, "Media image formats", "DiskCopy 6.5", "UDIF", "UDRAW");
public override IMediaImage Plugin => new Udif(); public override IMediaImage Plugin => new Udif();
public override BlockImageTestExpected[] Tests => new[] public override BlockImageTestExpected[] Tests => new[]

View File

@@ -35,11 +35,13 @@ using NUnit.Framework;
namespace Aaru.Tests.Images.DiskCopy65; namespace Aaru.Tests.Images.DiskCopy65;
[TestFixture, SuppressMessage("ReSharper", "InconsistentNaming")] [TestFixture]
[SuppressMessage("ReSharper", "InconsistentNaming")]
public class UDRO : BlockMediaImageTest public class UDRO : BlockMediaImageTest
{ {
public override string DataFolder => public override string DataFolder =>
Path.Combine(Consts.TestFilesRoot, "Media image formats", "DiskCopy 6.5", "UDIF", "UDRO"); Path.Combine(Consts.TestFilesRoot, "Media image formats", "DiskCopy 6.5", "UDIF", "UDRO");
public override IMediaImage Plugin => new Udif(); public override IMediaImage Plugin => new Udif();
public override BlockImageTestExpected[] Tests => new[] public override BlockImageTestExpected[] Tests => new[]

View File

@@ -35,11 +35,13 @@ using NUnit.Framework;
namespace Aaru.Tests.Images.DiskCopy65; namespace Aaru.Tests.Images.DiskCopy65;
[TestFixture, SuppressMessage("ReSharper", "InconsistentNaming")] [TestFixture]
[SuppressMessage("ReSharper", "InconsistentNaming")]
public class UDRo_obsolete : BlockMediaImageTest public class UDRo_obsolete : BlockMediaImageTest
{ {
public override string DataFolder => public override string DataFolder =>
Path.Combine(Consts.TestFilesRoot, "Media image formats", "DiskCopy 6.5", "UDIF", "UDRo_OBS"); Path.Combine(Consts.TestFilesRoot, "Media image formats", "DiskCopy 6.5", "UDIF", "UDRo_OBS");
public override IMediaImage Plugin => new Udif(); public override IMediaImage Plugin => new Udif();
public override BlockImageTestExpected[] Tests => new[] public override BlockImageTestExpected[] Tests => new[]

View File

@@ -38,6 +38,7 @@ public class DiskCopy42 : BlockMediaImageTest
{ {
public override string DataFolder => public override string DataFolder =>
Path.Combine(Consts.TestFilesRoot, "Media image formats", "DiskImagesFramework", "DiskCopy 4.2"); Path.Combine(Consts.TestFilesRoot, "Media image formats", "DiskImagesFramework", "DiskCopy 4.2");
public override IMediaImage Plugin => new DiscImages.DiskCopy42(); public override IMediaImage Plugin => new DiscImages.DiskCopy42();
public override BlockImageTestExpected[] Tests => new[] public override BlockImageTestExpected[] Tests => new[]

View File

@@ -35,11 +35,13 @@ using NUnit.Framework;
namespace Aaru.Tests.Images.DiskImagesFramework.NDIF; namespace Aaru.Tests.Images.DiskImagesFramework.NDIF;
[TestFixture, SuppressMessage("ReSharper", "InconsistentNaming")] [TestFixture]
[SuppressMessage("ReSharper", "InconsistentNaming")]
public class ROCo : BlockMediaImageTest public class ROCo : BlockMediaImageTest
{ {
public override string DataFolder => public override string DataFolder =>
Path.Combine(Consts.TestFilesRoot, "Media image formats", "DiskImagesFramework", "NDIF", "ROCo"); Path.Combine(Consts.TestFilesRoot, "Media image formats", "DiskImagesFramework", "NDIF", "ROCo");
public override IMediaImage Plugin => new Ndif(); public override IMediaImage Plugin => new Ndif();
public override BlockImageTestExpected[] Tests => new[] public override BlockImageTestExpected[] Tests => new[]

View File

@@ -39,6 +39,7 @@ public class RdWr : BlockMediaImageTest
{ {
public override string DataFolder => public override string DataFolder =>
Path.Combine(Consts.TestFilesRoot, "Media image formats", "DiskImagesFramework", "NDIF", "RdWr"); Path.Combine(Consts.TestFilesRoot, "Media image formats", "DiskImagesFramework", "NDIF", "RdWr");
public override IMediaImage Plugin => new Ndif(); public override IMediaImage Plugin => new Ndif();
public override BlockImageTestExpected[] Tests => new[] public override BlockImageTestExpected[] Tests => new[]

View File

@@ -39,6 +39,7 @@ public class Rdxx : BlockMediaImageTest
{ {
public override string DataFolder => public override string DataFolder =>
Path.Combine(Consts.TestFilesRoot, "Media image formats", "DiskImagesFramework", "NDIF", "Rdxx"); Path.Combine(Consts.TestFilesRoot, "Media image formats", "DiskImagesFramework", "NDIF", "Rdxx");
public override IMediaImage Plugin => new Ndif(); public override IMediaImage Plugin => new Ndif();
public override BlockImageTestExpected[] Tests => new[] public override BlockImageTestExpected[] Tests => new[]

Some files were not shown because too many files have changed in this diff Show More