public void CanReadLineNearEnd()
        {
            var stack = new BinaryStreamStack(Encoding.UTF8);

            stack.Push(TestUtil.StringToByteNoBom("\r\n--endboundary--"));

            Assert.Equal(stack.ReadLine(), string.Empty);
            Assert.Equal("--endboundary--", stack.ReadLine());
        }
        public void CanReadLineMultiplesLineInSingleBuffer()
        {
            var stack = new BinaryStreamStack(Encoding.UTF8);

            stack.Push(TestUtil.StringToByteNoBom("al" + Environment.NewLine));
            stack.Push(TestUtil.StringToByteNoBom("6chars" + Environment.NewLine + "5char" + Environment.NewLine + "Parti"));

            Assert.Equal("6chars", stack.ReadLine());
            Assert.Equal("5char", stack.ReadLine());
            Assert.Equal("Partial", stack.ReadLine());
        }
        public void ReadLineCanReadAcrossInterruption()
        {
            var stack = new BinaryStreamStack(Encoding.UTF8);

            stack.Push(TestUtil.StringToByteNoBom("6chars" + Environment.NewLine + "Resume" + Environment.NewLine));

            Assert.Equal("6chars", stack.ReadLine());

            stack.Push(TestUtil.StringToByteNoBom("Interrupt "));

            Assert.Equal("Interrupt Resume", stack.ReadLine());
        }
Пример #4
0
        public void ReadLineCanResumeInterruptedStream()
        {
            var stack = new BinaryStreamStack(Encoding.UTF8);

            stack.Push(TestUtil.StringToByteNoBom("6chars" + Environment.NewLine + "Resume" + Environment.NewLine));

            Assert.AreEqual(stack.ReadLine(), "6chars");

            stack.Push(TestUtil.StringToByteNoBom("Interrupt" + Environment.NewLine));

            Assert.AreEqual(stack.ReadLine(), "Interrupt");
            Assert.AreEqual(stack.ReadLine(), "Resume");
        }
        public void CanReadLineAcrossMultipleBuffers()
        {
            var stack = new BinaryStreamStack(Encoding.UTF8);

            stack.Push(TestUtil.StringToByteNoBom("13anotherline" + Environment.NewLine));
            stack.Push(TestUtil.StringToByteNoBom("ars" + Environment.NewLine));
            stack.Push(TestUtil.StringToByteNoBom("6ch"));

            string line = stack.ReadLine();

            Assert.Equal("6chars", line);

            line = stack.ReadLine();
            Assert.Equal("13anotherline", line);
        }
        public void MixReadAndReadLineWithInterrupt()
        {
            var stack = new BinaryStreamStack(Encoding.UTF8);

            stack.Push(TestUtil.StringToByteNoBom("6chars" + Environment.NewLine + "Resume" + Environment.NewLine));

            Assert.Equal('6', stack.Read());

            Assert.Equal("chars", stack.ReadLine());

            stack.Push(TestUtil.StringToByteNoBom("Interrupt" + Environment.NewLine));

            Assert.Equal("Interrupt", stack.ReadLine());
            Assert.Equal('R', stack.Read());
            Assert.Equal("esume", stack.ReadLine());
        }
        public void ReturnsNullOnNoStreams()
        {
            var stack = new BinaryStreamStack(Encoding.UTF8);

            string noline = stack.ReadLine();

            Assert.Null(noline);
        }
        public void ReturnsRemainderOnNoNewline()
        {
            var stack = new BinaryStreamStack(Encoding.UTF8);

            stack.Push(TestUtil.StringToByteNoBom("noline"));

            string noline = stack.ReadLine();

            Assert.Equal("noline", noline);
        }
        public void CanReadLineSingleBuffer()
        {
            var stack = new BinaryStreamStack(Encoding.UTF8);

            stack.Push(TestUtil.StringToByteNoBom("6chars" + Environment.NewLine));

            string result = stack.ReadLine();

            Assert.Equal("6chars", result);
        }
        public void CanReadLineSingleBuffer()
        {
            var stack = new BinaryStreamStack(Encoding.UTF8);

            stack.Push(TestUtil.StringToByteNoBom("6chars" + Environment.NewLine));

            var    buffer = new byte[Encoding.UTF8.GetByteCount("6chars" + Environment.NewLine)];
            string result = stack.ReadLine();

            Assert.Equal(result, "6chars");
        }