public void Crc32_OfNullFile_ThrowsArgumentNullException() { // We use a privately defined type for the storage access to check initialize and remove, which will // hopefully guarantee that we use the expected storage during this test. var storageAcces = new Crc32TestStorageAccess(); StreamUtilities.Initialize(storageAcces); var ignoreRanges = new[] { new Range <int>(10, 200) }; Assert.Throws <System.ArgumentNullException>(() => Crc32.OfFile(null)); Assert.Throws <System.ArgumentNullException>(() => Crc32.OfFile(null, ignoreRanges)); Assert.Throws <System.ArgumentNullException>(() => Crc32.OfFile(null, replaceFirstByte: true, alternateFirstByte: 0x42)); }
public void Crc32_OfFileWithAlternateFirstByte_IsCorrect() { // We use a privately defined type for the storage access to check initialize and remove, which will // hopefully guarantee that we use the expected storage during this test. var storageAcces = new Crc32TestStorageAccess(); var testFileName = "~/Crc32_OfFileWithAlternateFirstByte_IsCorrect.dat"; StreamUtilities.Initialize(storageAcces); using (var fileStream = StreamUtilities.OpenFileStream(testFileName)) { var testData = new byte[] { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }; fileStream.Write(testData, 0, testData.Length); var crc32 = Crc32.OfFile(testFileName, replaceFirstByte: true, alternateFirstByte: 0x42); Assert.Equal(0x066F5C62u, crc32); } }
public void Crc32_OfFileWithIgnoreRange_IsCorrect() { // We use a privately defined type for the storage access to check initialize and remove, which will // hopefully guarantee that we use the expected storage during this test. var storageAcces = new Crc32TestStorageAccess(); StreamUtilities.Initialize(storageAcces); var testFileName = "~/Crc32_OfFileWithIgnoreRange_IsCorrect.dat"; using (var fileStream = StreamUtilities.OpenFileStream(testFileName)) { var testData = new byte[] { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }; fileStream.Write(testData, 0, testData.Length); var ignoreRanges = new[] { new Range <int>(1, 2) }; var crc32 = Crc32.OfFile(testFileName, ignoreRanges); Assert.Equal(0xB4DA8CCAu, crc32); } }