public void WriterTaskExecutesWhenAddingChunkToQueue() { _fileReaderMock.Setup(x => x.GetChunkBytes(It.IsAny <ChunkReadInfo>())).Returns(It.IsAny <byte[]>()); _gzipCompressMock.Setup(x => x.Execute(It.IsAny <byte[]>())).Returns(It.IsAny <byte[]>()); _fileWriterTaskMock.Setup(x => x.AddChunk(It.IsAny <int>(), It.IsAny <ChunkWriteInfo>())); using (ChunksReader chunksReader = new ChunksReader(Environment.ProcessorCount, _fileReaderMock.Object, _gzipCompressMock.Object, _fileWriterTaskMock.Object, _errorLogsMock.Object)) { chunksReader.EnqueueChunk(new ChunkReadInfo(It.IsAny <int>(), It.IsAny <long>(), It.IsAny <int>())); Thread.Sleep(100); _fileWriterTaskMock.Verify(x => x.AddChunk(It.IsAny <int>(), It.IsAny <ChunkWriteInfo>()), Times.Once); } }
public void ReaderReturnsErrorIfReaderFails() { _fileReaderMock.Setup(x => x.GetChunkBytes(It.IsAny <ChunkReadInfo>())).Throws(new ReaderException("An unexpected error occurred")); _gzipCompressMock.Setup(x => x.Execute(It.IsAny <byte[]>())).Returns(It.IsAny <byte[]>()); _fileWriterTaskMock.Setup(x => x.AddChunk(It.IsAny <int>(), It.IsAny <ChunkWriteInfo>())); using (ChunksReader chunksReader = new ChunksReader(Environment.ProcessorCount, _fileReaderMock.Object, _gzipCompressMock.Object, _fileWriterTaskMock.Object, _errorLogsMock.Object)) { chunksReader.EnqueueChunk(new ChunkReadInfo(It.IsAny <int>(), It.IsAny <long>(), It.IsAny <int>())); Thread.Sleep(100); _fileReaderMock.Verify(x => x.GetChunkBytes(It.IsAny <ChunkReadInfo>()), Times.Once); _gzipCompressMock.Verify(x => x.Execute(It.IsAny <byte[]>()), Times.Never); } }