Use Stream extension to ensure read operations return the requested number of bytes (unless EOF arrives first).

This commit is contained in:
2022-11-14 09:43:16 +00:00
parent f90cc6593f
commit 0eb589d785
178 changed files with 862 additions and 780 deletions

View File

@@ -31,6 +31,7 @@ namespace Aaru.Tests.Checksums;
using System.IO;
using Aaru.Checksums;
using Aaru.CommonTypes.Interfaces;
using Aaru.Helpers;
using FluentAssertions;
using NUnit.Framework;
@@ -60,7 +61,7 @@ public class Sha512
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open,
FileAccess.Read);
fs.Read(data, 0, 1048576);
fs.EnsureRead(data, 0, 1048576);
fs.Close();
fs.Dispose();
Sha512Context.Data(data, out byte[] result);
@@ -82,7 +83,7 @@ public class Sha512
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "empty"), FileMode.Open,
FileAccess.Read);
fs.Read(data, 0, 1048576);
fs.EnsureRead(data, 0, 1048576);
fs.Close();
fs.Dispose();
IChecksum ctx = new Sha512Context();
@@ -99,7 +100,7 @@ public class Sha512
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read);
fs.Read(data, 0, 1048576);
fs.EnsureRead(data, 0, 1048576);
fs.Close();
fs.Dispose();
Sha512Context.Data(data, out byte[] result);
@@ -121,7 +122,7 @@ public class Sha512
var fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "Checksum test files", "random"), FileMode.Open,
FileAccess.Read);
fs.Read(data, 0, 1048576);
fs.EnsureRead(data, 0, 1048576);
fs.Close();
fs.Dispose();
IChecksum ctx = new Sha512Context();