public void DocumentStream_Write_WritesDataCorrectly(byte[] data) { var path = GetTempFileName(); var filename = RandomFileName(); using (var writable = V8Container.Create(path)) { var file = writable.CreateFile(filename); using (var stream = file.Open()) { stream.Write(data.AsSpan()); } } using (var readable = V8Container.Open(path)) { var file = readable.GetFile(filename); var expectedHash = Hash.ComputeHash(data); using (var stream = file.Open()) { var hash = Hash.ComputeHash(stream); using (var scope = new AssertionScope()) { stream.Length.Should().Be(data.Length); hash.Should().Equal(expectedHash); } } } }
protected V8Container ReadOnlyContainer() { var container = V8Container.Open(ReadOnlyContainerPath); _disposables.Add(container); return(container); }
public void V8Container_Open_OpensContainer() { using (var container = V8Container.Open(ReadOnlyContainerPath)) { container.Should().NotBeNull(); container.Files.Should().NotBeNullOrEmpty(); } }
protected V8Container NewContainer() { var baseStream = SparseMemoryStream.WritableStream(); var container = new V8Container(baseStream, V8ContainerMode.Write); _disposables.Add(container); return(container); }
public void V8Container_Create_CreatesEmptyContainer() { var path = GetTempFileName(); using (var container = V8Container.Create(path)) { container.Should().NotBeNull(); container.Files.Should().BeEmpty(); } }
public void DocumentStream_Write_WritesData(byte[] data) { var path = GetTempFileName(); var filename = RandomFileName(); using (var writable = V8Container.Create(path)) { var file = writable.CreateFile(filename); using (var stream = file.Open()) { stream.Write(data.AsSpan()); using (var scope = new AssertionScope()) { stream.Length.Should().Be(data.Length); stream.Position.Should().Be(data.Length); } } } }
private Page(V8Container container, long start, in PageHeader header, int startInDocument = 0)