public void CreateDragonTapeDataBlock_Empty() { var block = new DragonTapeDataBlock(null); Assert.Equal(DragonTapeBlockType.Data, block.BlockType); Assert.Equal(0, block.Length); Assert.Null(block.Data); Assert.Equal(1, block.Checksum); block.Validate(); }
public void CreateDragonTapeDataBlock_PayloadTooLarge_ThrowsException() { var payload = new byte[256]; DragonTapeBlock block = null; try { block = new DragonTapeDataBlock(payload); Assert.True(false, "Block with too large payload incorrectly created."); } catch (ArgumentOutOfRangeException) {} }
public void CreateDragonTapeDataBlock() { var payload = new byte[] {0x10, 0x20, 0x30, 0x01, 0x02, 0x03, 0x55, 0xaa}; var block = new DragonTapeDataBlock(payload); Assert.AreEqual(DragonTapeBlockType.Data, block.BlockType); Assert.AreEqual(payload.Length, block.Length); var data = block.Data; for (int i = 0; i < data.Length; i++ ) Assert.AreEqual(payload[i], data[i]); Assert.AreEqual(0x6e, block.Checksum); block.Validate(); }
public void CreateDragonTapeDataBlock() { var payload = new byte[] { 0x10, 0x20, 0x30, 0x01, 0x02, 0x03, 0x55, 0xaa }; var block = new DragonTapeDataBlock(payload); Assert.Equal(DragonTapeBlockType.Data, block.BlockType); Assert.Equal(payload.Length, block.Length); var data = block.Data; for (int i = 0; i < data.Length; i++) { Assert.Equal(payload[i], data[i]); } Assert.Equal(0x6e, block.Checksum); block.Validate(); }
public void CreateDragonTapeDataBlock_PayloadTooLarge_ThrowsException() { var payload = new byte[256]; DragonTapeBlock block = null; try { block = new DragonTapeDataBlock(payload); Assert.Fail("Block with too large payload incorrectly created."); } catch (ArgumentOutOfRangeException) {} }
public void CreateDragonTapeDataBlock_Empty() { var block = new DragonTapeDataBlock(null); Assert.AreEqual(DragonTapeBlockType.Data, block.BlockType); Assert.AreEqual(0, block.Length); Assert.AreEqual(null, block.Data); Assert.AreEqual(1, block.Checksum); block.Validate(); }
private void WriteDataBlocks(DragonFile file) { int blocks = (file.Length + 254)/255; // number of data blocks to write int offset = 0; bool firstblock = true; // make sure to create a long leader for the first data block for (int i = 0; i < blocks; i++ ) { var block = new DragonTapeDataBlock(file.GetData(), offset, Math.Min(255, file.Length - offset)); block.WriteBlock(Tape, !(firstblock || file.IsGapped)); offset += 255; firstblock = false; } }