Ejemplo n.º 1
0
        public void No_Bold_Claims()
        {
            //Arrange
            var    functions     = new Mock <Functions>();
            var    writeCalls    = new List <(long, int)>();
            var    namespaceVirt = (IntPtr)7;
            var    dataStreamId  = Guid.NewGuid();
            var    allocSize     = (2 << 12);
            IntPtr buffer        = Marshal.AllocHGlobal(allocSize);
            var    aligned       = AlignedBufferHandle.FromIntPtr(functions.Object, buffer);

            functions.Setup(f => f.PrjAllocateAlignedBuffer(namespaceVirt, (UIntPtr)allocSize)).Returns(aligned);

            //Act
            var stream = new FileWriteStream(0, allocSize, namespaceVirt, dataStreamId, functions.Object);

            //Assert
            var tempBuffer = new byte[200];

            Assert.False(stream.CanRead);
            Assert.False(stream.CanSeek);
            Assert.True(stream.CanWrite);
            Assert.Throws <NotSupportedException>(() => stream.Read(tempBuffer, 0, tempBuffer.Length));
            Assert.Throws <NotSupportedException>(() => stream.Seek(0, System.IO.SeekOrigin.Begin));
            Assert.Throws <NotSupportedException>(() => stream.SetLength(0));
            Assert.Throws <NotSupportedException>(() => stream.Position = 10);
            Assert.Throws <NotSupportedException>(() => { var item = stream.Position; });
            Assert.Throws <NotSupportedException>(() => { var length = stream.Length; });
        }