public void ArgumentExceptionOffsetAndCount() { using (CharArrayTextReader tr = GetCharArray().textReader) { AssertExtensions.Throws <ArgumentException>(null, () => tr.Read(new char[0], 2, 0)); } }
public void ArgumentOutOfRangeOnInvalidOffset() { using (CharArrayTextReader tr = GetCharArray().textReader) { Assert.Throws <ArgumentOutOfRangeException>(() => tr.Read(new char[0], -1, 0)); } }
public void ReadZeroCharacters() { using (CharArrayTextReader tr = GetCharArray().textReader) { Assert.Equal(0, tr.Read(new char[0], 0, 0)); } }
public void ArgumentOutOfRangeOnNegativCount() { using (CharArrayTextReader tr = GetCharArray().textReader) { AssertExtensions.Throws <ArgumentException>(null, () => tr.Read(new char[0], 0, 1)); } }
public void ArgumentNullOnNullArray() { (char[] chArr, CharArrayTextReader textReader)baseInfo = GetCharArray(); using (CharArrayTextReader tr = baseInfo.textReader) { Assert.Throws <ArgumentNullException>(() => tr.Read(null, 0, 0)); } }
public void EmptyInput() { using (CharArrayTextReader tr = new CharArrayTextReader(new char[] { })) { char[] buffer = new char[10]; int read = tr.Read(buffer, 0, 1); Assert.Equal(0, read); } }
public void TestRead() { (char[] chArr, CharArrayTextReader textReader)baseInfo = GetCharArray(); using (CharArrayTextReader tr = baseInfo.textReader) { for (int count = 0; count < baseInfo.chArr.Length; ++count) { int tmp = tr.Read(); Assert.Equal((int)baseInfo.chArr[count], tmp); } } }
public void NotEndOfStream() { using (CharArrayTextReader tr = new CharArrayTextReader(TestDataProvider.SmallData)) { char[] charBuff = new char[3]; var result = tr.Read(charBuff, 0, 3); Assert.Equal(3, result); Assert.Equal("HEL", new string(charBuff)); Assert.False(tr.EndOfStream, "End of TextReader was true after ReadToEnd"); } }
public void ReadLines2() { (char[] chArr, CharArrayTextReader textReader)baseInfo = GetCharArray(); using (CharArrayTextReader tr = baseInfo.textReader) { string valueString = new string(baseInfo.chArr); char[] temp = new char[10]; tr.Read(temp, 0, 1); var data = tr.ReadLine(); Assert.Equal(valueString.Substring(1, valueString.IndexOf('\r') - 1), data); } }
public void ReadCharArr() { (char[] chArr, CharArrayTextReader textReader)baseInfo = GetCharArray(); using (CharArrayTextReader tr = baseInfo.textReader) { char[] chArr = new char[baseInfo.chArr.Length]; var read = tr.Read(chArr, 0, chArr.Length); Assert.Equal(chArr.Length, read); for (int count = 0; count < baseInfo.chArr.Length; ++count) { Assert.Equal(baseInfo.chArr[count], chArr[count]); } } }
public void ReadSpan() { (char[] chArr, CharArrayTextReader textReader)baseInfo = GetCharArray(); using (CharArrayTextReader tr = baseInfo.textReader) { char[] chArr = new char[baseInfo.chArr.Length]; var chSpan = new Span <char>(chArr, 0, baseInfo.chArr.Length); var read = tr.Read(chSpan); Assert.Equal(chArr.Length, read); for (int i = 0; i < baseInfo.chArr.Length; i++) { Assert.Equal(baseInfo.chArr[i], chArr[i]); } } }