Example #1
0
        public void Peek_And_Read_Works_As_Expected_Without_Altering_StringBuilder()
        {
            var sb = new StringBuilder("T");

            using (var sbreader = new SbReader(sb))
            {
                Assert.True(sbreader.Peek().Equals('T'));
                Assert.True(sbreader.Read().Equals('T'));
                Assert.True(sbreader.Peek().Equals(-1));
                Assert.True(sbreader.Read().Equals(-1));
            }
            Assert.True(sb.ToString().Equals("T"));
        }
Example #2
0
        public void Dispose_Simply_Changes_Internal_State_Without_Altering_StringBuilder()
        {
            var sb       = new StringBuilder("Testing");
            var sbreader = new SbReader(sb);

            using (sbreader)
            {
            }
            var err = Assert.Throws <DdnDfException>(() => Assert.Null(sbreader.Peek()));

            Assert.True(err.ErrorCode == DdnDfErrorCode.NullObject);
            Assert.True(err.Message.Contains("closed/disposed"));
            Assert.True(sb.ToString().Equals("Testing"));
        }