Ejemplo n.º 1
0
        public void CustomEndSentinel_Test()
        {
            var memoryStream = new MemoryStream();

            memoryStream.Write(new byte[] { 1, 2, 3 }, 0, 3);
            memoryStream.Seek(0, SeekOrigin.Begin);
            var target = new StreamByteSequence(memoryStream, new StreamByteSequence.Options {
                BufferSize = 5, EndSentinel = 9
            });

            target.GetNext().Should().Be(1);
            target.GetNext().Should().Be(2);
            target.GetNext().Should().Be(3);
            target.GetNext().Should().Be(9);
        }
Ejemplo n.º 2
0
        public void FileStream_Test()
        {
            var fileName = Guid.NewGuid().ToString() + ".txt";

            try
            {
                File.WriteAllText(fileName, "test");
                using var target = new StreamByteSequence(new StreamByteSequence.Options { FileName = fileName });
                target.GetNext().Should().Be((byte)'t');
                target.GetNext().Should().Be((byte)'e');
                target.GetNext().Should().Be((byte)'s');
                target.GetNext().Should().Be((byte)'t');
            }
            finally
            {
                if (File.Exists(fileName))
                {
                    File.Delete(fileName);
                }
            }
        }