public async Task Read_NegativeAbsoluteOffset_InvalidOperationExceptionThrown() { var fs = new MockFileSystem(); fs.AddFile("test.dat", new MockFileData(new byte[] { 0x1, 0x2, 0x3, 0x4, 0x5 })); // -4 + 0 == negative absolute offset var data = new TestDataType(-4); await Assert.ThrowsAsync <InvalidOperationException>(async() => { using (var file = fs.File.OpenRead("test.dat")) { await data.ReadAsync(file, 0, new NefsProgress()); } }); }
public async Task Read_PastEndOfFile_InvalidOperationExceptionThrown() { var fs = new MockFileSystem(); fs.AddFile("test.dat", new MockFileData(new byte[] { 0x1, 0x2, 0x3, 0x4, 0x5 })); // 0 + 10 == past end of file var data = new TestDataType(0); await Assert.ThrowsAsync <InvalidOperationException>(async() => { using (var file = fs.File.OpenRead("test.dat")) { await data.ReadAsync(file, 10, new NefsProgress()); } }); }
public async Task Read_PositiveDataOffset_ReadSuccess() { var fs = new MockFileSystem(); fs.AddFile("test.dat", new MockFileData(new byte[] { 0x1, 0x2, 0x3, 0x4, 0x5 })); // 1 + 0 == positive absolute offset var data = new TestDataType(1); using (var file = fs.File.OpenRead("test.dat")) { await data.ReadAsync(file, 0, new NefsProgress()); } var expected = new byte[] { 0x2, 0x3, 0x4, 0x5 }; Assert.Equal(expected, data.GetBytes()); }
public async Task Read_NullStream_ArgumentNullExceptionThrown() { var data = new TestDataType(0); await Assert.ThrowsAsync <ArgumentNullException>(async() => await data.ReadAsync(null, 0, new NefsProgress())); }