Example #1
0
        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);
                    }
                }
            }
        }
Example #2
0
        protected V8Container ReadOnlyContainer()
        {
            var container = V8Container.Open(ReadOnlyContainerPath);

            _disposables.Add(container);

            return(container);
        }
Example #3
0
 public void V8Container_Open_OpensContainer()
 {
     using (var container = V8Container.Open(ReadOnlyContainerPath))
     {
         container.Should().NotBeNull();
         container.Files.Should().NotBeNullOrEmpty();
     }
 }
Example #4
0
        protected V8Container NewContainer()
        {
            var baseStream = SparseMemoryStream.WritableStream();
            var container  = new V8Container(baseStream, V8ContainerMode.Write);

            _disposables.Add(container);

            return(container);
        }
Example #5
0
        public void V8Container_Create_CreatesEmptyContainer()
        {
            var path = GetTempFileName();

            using (var container = V8Container.Create(path))
            {
                container.Should().NotBeNull();
                container.Files.Should().BeEmpty();
            }
        }
Example #6
0
        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);
                    }
                }
            }
        }
Example #7
0
 private Page(V8Container container, long start, in PageHeader header, int startInDocument = 0)