public static void MiscWrites() { var sw = new ArrayPooledTextWriter(); sw.Write('H'); sw.Write("ello World!"); Assert.Equal("Hello World!", sw.ToString()); }
private IMemoryOwner <char> GetEngineCodeExecute() { using (var writer = new ArrayPooledTextWriter()) { writer.Write(ServerOnly ? "ReactDOMServer.renderToStaticMarkup(React.createElement(" : "ReactDOMServer.renderToString(React.createElement("); writer.Write(ComponentName); writer.Write(','); WriterSerialziedProps(writer); writer.Write("))"); return(writer.GetMemoryOwner()); } }
public static void SimpleWriter() { var sw = new ArrayPooledTextWriter(); sw.Write(4); Assert.Equal("4", sw.ToString()); }
public static void TestWriteObject() { var sw = new ArrayPooledTextWriter(); sw.Write(new object()); Assert.Equal("System.Object", sw.ToString()); }
public static void ToStringReturnsWrittenData() { var sb = getSb().ToString(); ArrayPooledTextWriter sw = new ArrayPooledTextWriter(); sw.Write(sb); Assert.Equal(sb, sw.ToString()); }
public static void WriteWithLargeIndex() { for (int i = 0; i < iArrValidValues.Length; i++) { var sb = new StringBuilder(int.MaxValue / 2000).ToString(); ArrayPooledTextWriter sw = new ArrayPooledTextWriter(); sw.Write(sb); var chArr = new char[int.MaxValue / 2000]; for (int j = 0; j < chArr.Length; j++) { chArr[j] = (char)(j % 256); } sw.Write(chArr, iArrValidValues[i] - 1, 1); string strTemp = sw.ToString(); Assert.Equal(1, strTemp.Length); } }
public static void WriteWithOffset() { ArrayPooledTextWriter sw = new ArrayPooledTextWriter(); StringReader sr; var chArr = TestDataProvider.CharData; sw.Write(chArr, 2, 5); sr = new StringReader(sw.ToString()); for (int i = 2; i < 7; i++) { int tmp = sr.Read(); Assert.Equal((int)chArr[i], tmp); } }
private IMemoryOwner<char> GetEngineCodeExecute() { using (var textWriter = new ArrayPooledTextWriter()) { textWriter.Write("var context={};"); textWriter.Write("Object.assign(context, {html:"); textWriter.Write(ServerOnly ? "ReactDOMServer.renderToStaticMarkup(React.createElement(" : "ReactDOMServer.renderToString(React.createElement("); textWriter.Write(ComponentName); textWriter.Write(",Object.assign("); WriterSerialziedProps(textWriter); textWriter.Write(",{location:"); textWriter.Write(JsonConvert.SerializeObject(Path, _configuration.JsonSerializerSettings)); textWriter.Write(",context:context})))"); textWriter.Write("})"); return textWriter.GetMemoryOwner(); } }
public static void WriteArray() { var chArr = TestDataProvider.LargeData; var sb = getSb().ToString(); ArrayPooledTextWriter sw = new ArrayPooledTextWriter(); sw.Write(sb); var sr = new StringReader(sw.ToString()); for (int i = 0; i < chArr.Length; i++) { int tmp = sr.Read(); Assert.Equal((int)chArr[i], tmp); } }
private IMemoryOwner <char> GetEngineCodeExecute() { using (var textWriter = new ArrayPooledTextWriter()) { textWriter.Write("var context={};"); textWriter.Write(ServerOnly ? "ReactDOMServer.renderToStaticMarkup(React.createElement(" : "ReactDOMServer.renderToString(React.createElement("); textWriter.Write(ComponentName); textWriter.Write(",Object.assign("); WriterSerialziedProps(textWriter); textWriter.Write(",{location:\""); textWriter.Write(Path); textWriter.Write("\",context:context})))"); return(textWriter.GetMemoryOwner()); } }
public static void CantWriteNegativeCount() { var sw = new ArrayPooledTextWriter(); Assert.Throws <ArgumentOutOfRangeException>(() => sw.Write(new char[0], 0, -1)); }
public static void CantWriteNullArray() { var sw = new ArrayPooledTextWriter(); Assert.Throws <ArgumentNullException>(() => sw.Write(null, 0, 0)); }
private static void ValidateDisposedExceptions(ArrayPooledTextWriter sw) { Assert.Throws <ObjectDisposedException>(() => { sw.Write('a'); }); Assert.Throws <ObjectDisposedException>(() => { sw.Write(new char[10], 0, 1); }); Assert.Throws <ObjectDisposedException>(() => { sw.Write("abc"); }); }