コード例 #1
0
        public void WriteMarker_WritesToPlacedPosition()
        {
            using var stream = new MemoryStream();

            using (var writer = new TiffStreamWriter(stream))
            {
                writer.Write(0x11111111);
                long marker = writer.PlaceMarker();
                writer.Write(0x33333333);

                writer.WriteMarker(marker, 0x12345678);

                writer.Write(0x44444444);
            }

            Assert.Equal(
                new byte[]
            {
                0x11, 0x11, 0x11, 0x11,
                0x78, 0x56, 0x34, 0x12,
                0x33, 0x33, 0x33, 0x33,
                0x44, 0x44, 0x44, 0x44
            },
                stream.ToArray());
        }
コード例 #2
0
 public void Position_EqualsTheStreamPosition(byte[] data, long expectedResult)
 {
     using var stream = new MemoryStream();
     using var writer = new TiffStreamWriter(stream);
     writer.Write(data);
     Assert.Equal(writer.Position, expectedResult);
 }
コード例 #3
0
        public void Write_WritesUInt32()
        {
            using var stream = new MemoryStream();
            using var writer = new TiffStreamWriter(stream);
            writer.Write(12345678U);

            Assert.Equal(new byte[] { 0x4E, 0x61, 0xBC, 0x00 }, stream.ToArray());
        }
コード例 #4
0
        public void Write_WritesUInt16()
        {
            using var stream = new MemoryStream();
            using var writer = new TiffStreamWriter(stream);
            writer.Write(1234);

            Assert.Equal(new byte[] { 0xD2, 0x04 }, stream.ToArray());
        }
コード例 #5
0
        public void Write_WritesByteArray()
        {
            using var stream = new MemoryStream();
            using var writer = new TiffStreamWriter(stream);
            writer.Write(new byte[] { 2, 4, 6, 8 });

            Assert.Equal(new byte[] { 2, 4, 6, 8 }, stream.ToArray());
        }