public void CidaChunkTest() { Mock <IDjvuReader> readerMock = new Mock <IDjvuReader>(); readerMock.Setup(x => x.Position).Returns(1024); CidaChunk unk = new CidaChunk(readerMock.Object, null, null, null, 0); Assert.Equal <ChunkType>(ChunkType.Cida, unk.ChunkType); Assert.Equal(ChunkType.Cida.ToString(), unk.Name); Assert.Equal <long>(1024, unk.DataOffset); }
public void ReadDataTest() { Mock <IDjvuReader> readerMock = new Mock <IDjvuReader>(); readerMock.SetupProperty <long>(x => x.Position); IDjvuReader reader = readerMock.Object; reader.Position = 1024; CidaChunk unk = new CidaChunk(reader, null, null, null, 1024); Assert.Equal <ChunkType>(ChunkType.Cida, unk.ChunkType); Assert.Equal(ChunkType.Cida.ToString(), unk.Name); Assert.Equal <long>(1024, unk.DataOffset); unk.ReadData(reader); Assert.Equal <long>(2048, reader.Position); }
/// <summary> /// Builds the appropriate chunk for the ID /// </summary> /// <returns></returns> public static IDjvuNode CreateDecodedDjvuNode(IDjvuReader reader, IDjvuDocument rootDocument, IDjvuElement parent, ChunkType chunkType, string chunkID = "", long length = 0) { IDjvuNode result = null; switch (chunkType) { case ChunkType.Djvm: result = new DjvmChunk(reader, parent, rootDocument, chunkID, length); break; case ChunkType.Djvu: result = new DjvuChunk(reader, parent, rootDocument, chunkID, length); break; case ChunkType.Djvi: result = new DjviChunk(reader, parent, rootDocument, chunkID, length); break; case ChunkType.Thum: result = new ThumChunk(reader, parent, rootDocument, chunkID, length); break; case ChunkType.Dirm: result = new DirmChunk(reader, parent, rootDocument, chunkID, length); break; case ChunkType.Navm: result = new NavmChunk(reader, parent, rootDocument, chunkID, length); break; case ChunkType.Anta: result = new AntaChunk(reader, parent, rootDocument, chunkID, length); break; case ChunkType.Antz: result = new AntzChunk(reader, parent, rootDocument, chunkID, length); break; case ChunkType.Txta: result = new TxtaChunk(reader, parent, rootDocument, chunkID, length); break; case ChunkType.Txtz: result = new TxtzChunk(reader, parent, rootDocument, chunkID, length); break; case ChunkType.Djbz: result = new DjbzChunk(reader, parent, rootDocument, chunkID, length); break; case ChunkType.Sjbz: result = new SjbzChunk(reader, parent, rootDocument, chunkID, length); break; case ChunkType.FG44: result = new FG44Chunk(reader, parent, rootDocument, chunkID, length); break; case ChunkType.BG44: result = new BG44Chunk(reader, parent, rootDocument, chunkID, length); break; case ChunkType.TH44: result = new TH44Chunk(reader, parent, rootDocument, chunkID, length); break; case ChunkType.BM44: result = new BM44Chunk(reader, parent, rootDocument, chunkID, length); break; case ChunkType.BM44Form: result = new BM44Form(reader, parent, rootDocument, chunkID, length); break; case ChunkType.PM44: result = new PM44Chunk(reader, parent, rootDocument, chunkID, length); break; case ChunkType.PM44Form: result = new PM44Form(reader, parent, rootDocument, chunkID, length); break; case ChunkType.Wmrm: result = new WmrmChunk(reader, parent, rootDocument, chunkID, length); break; case ChunkType.FGbz: result = new FGbzChunk(reader, parent, rootDocument, chunkID, length); break; case ChunkType.Info: result = new InfoChunk(reader, parent, rootDocument, chunkID, length); break; case ChunkType.Incl: result = new InclChunk(reader, parent, rootDocument, chunkID, length); break; case ChunkType.BGjp: result = new BGjpChunk(reader, parent, rootDocument, chunkID, length); break; case ChunkType.FGjp: result = new FGjpChunk(reader, parent, rootDocument, chunkID, length); break; case ChunkType.Smmr: result = new SmmrChunk(reader, parent, rootDocument, chunkID, length); break; case ChunkType.Cida: result = new CidaChunk(reader, parent, rootDocument, chunkID, length); break; default: result = new UnknownChunk(reader, parent, rootDocument, chunkID, length); break; } return(result); }