Skip to content

Commit

Permalink
[Aaru.Tests] Reformat and cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
claunia committed Oct 3, 2023
1 parent 4b7fe8a commit 1f36ef2
Show file tree
Hide file tree
Showing 171 changed files with 1,435 additions and 1,488 deletions.
24 changes: 12 additions & 12 deletions Aaru.Tests/Aaru.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Claunia.Encoding" Version="1.9.2" />
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="nunit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<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="Claunia.Encoding" Version="1.9.2"/>
<PackageReference Include="FluentAssertions" Version="6.12.0"/>
<PackageReference Include="nunit" Version="3.13.3"/>
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2"/>
<PackageReference Include="System.Text.Encoding.CodePages" Version="8.0.0-rc.1.23419.4"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Aaru.Checksums\Aaru.Checksums.csproj" />
<ProjectReference Include="..\Aaru.CommonTypes\Aaru.CommonTypes.csproj" />
<ProjectReference Include="..\Aaru.Core\Aaru.Core.csproj" />
<ProjectReference Include="..\Aaru.Filesystems\Aaru.Filesystems.csproj" />
<ProjectReference Include="..\Aaru.Filters\Aaru.Filters.csproj" />
<ProjectReference Include="..\Aaru.Images\Aaru.Images.csproj" />
<ProjectReference Include="..\Aaru.Checksums\Aaru.Checksums.csproj"/>
<ProjectReference Include="..\Aaru.CommonTypes\Aaru.CommonTypes.csproj"/>
<ProjectReference Include="..\Aaru.Core\Aaru.Core.csproj"/>
<ProjectReference Include="..\Aaru.Filesystems\Aaru.Filesystems.csproj"/>
<ProjectReference Include="..\Aaru.Filters\Aaru.Filters.csproj"/>
<ProjectReference Include="..\Aaru.Images\Aaru.Images.csproj"/>
</ItemGroup>

<ItemGroup>
Expand Down
5 changes: 3 additions & 2 deletions Aaru.Tests/Aaru.Tests.csproj.DotSettings
Original file line number Diff line number Diff line change
@@ -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"
xml:space="preserve">
<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>
99 changes: 42 additions & 57 deletions Aaru.Tests/Checksums/Adler32.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,40 +38,25 @@ namespace Aaru.Tests.Checksums;
[TestFixture]
public class Adler32
{
static readonly byte[] _expectedEmpty =
{
0x00, 0xf0, 0x00, 0x01
};
static readonly byte[] _expectedEmpty = { 0x00, 0xf0, 0x00, 0x01 };
static readonly byte[] _expectedRandom =
{
// ReSharper disable once UseUtf8StringLiteral
0x37, 0x28, 0xd1, 0x86
};

static readonly byte[] _expectedRandom15 =
{
0x34, 0xDC, 0x06, 0x7D
};
static readonly byte[] _expectedRandom15 = { 0x34, 0xDC, 0x06, 0x7D };

static readonly byte[] _expectedRandom31 =
{
0xD8, 0xF1, 0x0E, 0xAA
};
static readonly byte[] _expectedRandom31 = { 0xD8, 0xF1, 0x0E, 0xAA };

static readonly byte[] _expectedRandom63 =
{
0xD8, 0xAC, 0x20, 0x81
};
static readonly byte[] _expectedRandom63 = { 0xD8, 0xAC, 0x20, 0x81 };

static readonly byte[] _expectedRandom2352 =
{
0xEC, 0xD1, 0x73, 0x8B
};
static readonly byte[] _expectedRandom2352 = { 0xEC, 0xD1, 0x73, 0x8B };

[Test]
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,
FileAccess.Read);
Expand All @@ -93,7 +78,7 @@ public void EmptyFile()
[Test]
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,
FileAccess.Read);
Expand All @@ -108,109 +93,109 @@ public void EmptyInstance()
}

[Test]
public void RandomData()
public void PartialInstanceAuto15()
{
byte[] data = new byte[1048576];
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, 1048576);
fs.EnsureRead(data, 0, 15);
fs.Close();
fs.Dispose();
Adler32Context.Data(data, out byte[] result);
result.Should().BeEquivalentTo(_expectedRandom);
}

[Test]
public void RandomFile()
{
byte[] result = Adler32Context.File(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"));
result.Should().BeEquivalentTo(_expectedRandom);
IChecksum ctx = new Adler32Context();
ctx.Update(data);
byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom15);
}

[Test]
public void RandomInstance()
public void PartialInstanceAuto2352()
{
byte[] data = new byte[1048576];
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, 1048576);
fs.EnsureRead(data, 0, 2352);
fs.Close();
fs.Dispose();
IChecksum ctx = new Adler32Context();
ctx.Update(data);
byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom);
result.Should().BeEquivalentTo(_expectedRandom2352);
}

[Test]
public void PartialInstanceAuto15()
public void PartialInstanceAuto31()
{
byte[] data = new byte[15];
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, 15);
fs.EnsureRead(data, 0, 31);
fs.Close();
fs.Dispose();
IChecksum ctx = new Adler32Context();
ctx.Update(data);
byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom15);
result.Should().BeEquivalentTo(_expectedRandom31);
}

[Test]
public void PartialInstanceAuto31()
public void PartialInstanceAuto63()
{
byte[] data = new byte[31];
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, 31);
fs.EnsureRead(data, 0, 63);
fs.Close();
fs.Dispose();
IChecksum ctx = new Adler32Context();
ctx.Update(data);
byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom31);
result.Should().BeEquivalentTo(_expectedRandom63);
}

[Test]
public void PartialInstanceAuto63()
public void RandomData()
{
byte[] data = new byte[63];
var data = new byte[1048576];

var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read);

fs.EnsureRead(data, 0, 63);
fs.EnsureRead(data, 0, 1048576);
fs.Close();
fs.Dispose();
IChecksum ctx = new Adler32Context();
ctx.Update(data);
byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom63);
Adler32Context.Data(data, out byte[] result);
result.Should().BeEquivalentTo(_expectedRandom);
}

[Test]
public void PartialInstanceAuto2352()
public void RandomFile()
{
byte[] data = new byte[2352];
byte[] result = Adler32Context.File(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"));
result.Should().BeEquivalentTo(_expectedRandom);
}

[Test]
public void RandomInstance()
{
var data = new byte[1048576];

var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read);

fs.EnsureRead(data, 0, 2352);
fs.EnsureRead(data, 0, 1048576);
fs.Close();
fs.Dispose();
IChecksum ctx = new Adler32Context();
ctx.Update(data);
byte[] result = ctx.Final();
result.Should().BeEquivalentTo(_expectedRandom2352);
result.Should().BeEquivalentTo(_expectedRandom);
}
}
Loading

0 comments on commit 1f36ef2

Please sign in to comment.