public WriteToAnEmptyBookmarkStream() { var fileSystemAdapter = Substitute.For <IFileSystemAdapter>(); fileSystemAdapter .Open(Arg.Any <string>(), Arg.Any <FileMode>(), Arg.Any <FileAccess>(), Arg.Any <FileShare>()) .Returns(_sut); var provider = new FileBasedBookmarkProvider(BaseBufferFileName, fileSystemAdapter, Encoder); provider.UpdateBookmark(new FileSetPosition(ExpectedBytePosition, ExpectedBufferFilePath)); _expectedBytes = Encoder.GetBytes(_expectedFileContent); _actualBytes = _sut.ToArray(); }
public WriteToAnBookmarkStreamWithExistingContent() { //simulate a stream with existing content that may be larger or shorter than what is written. // newline detection ends up being iportant in this case var initialContent = Encoder.GetBytes($"100000:::{ExpectedBufferFilePath}{ExpectedBufferFilePath}\r\n"); _sut.Write(initialContent, 0, initialContent.Length); var fileSystemAdapter = Substitute.For <IFileSystemAdapter>(); fileSystemAdapter .Open(Arg.Any <string>(), Arg.Any <FileMode>(), Arg.Any <FileAccess>(), Arg.Any <FileShare>()) .Returns(_sut); var provider = new FileBasedBookmarkProvider(BaseBufferFileName, fileSystemAdapter, Encoder); provider.UpdateBookmark(new FileSetPosition(ExpectedBytePosition, ExpectedBufferFilePath)); _expectedBytes = Encoder.GetBytes(_expectedFileContent); _actualBytes = _sut.ToArray(); }