Exemplo n.º 1
0
        public static void MiscWrites()
        {
            var sw = new ArrayPooledTextWriter();

            sw.Write('H');
            sw.Write("ello World!");

            Assert.Equal("Hello World!", sw.ToString());
        }
Exemplo n.º 2
0
        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());
            }
        }
Exemplo n.º 3
0
        public static void SimpleWriter()
        {
            var sw = new ArrayPooledTextWriter();

            sw.Write(4);
            Assert.Equal("4", sw.ToString());
        }
Exemplo n.º 4
0
        public static void TestWriteObject()
        {
            var sw = new ArrayPooledTextWriter();

            sw.Write(new object());
            Assert.Equal("System.Object", sw.ToString());
        }
Exemplo n.º 5
0
        public static void ToStringReturnsWrittenData()
        {
            var sb = getSb().ToString();
            ArrayPooledTextWriter sw = new ArrayPooledTextWriter();

            sw.Write(sb);

            Assert.Equal(sb, sw.ToString());
        }
Exemplo n.º 6
0
        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);
            }
        }
Exemplo n.º 7
0
        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);
            }
        }
Exemplo n.º 8
0
        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();
            }
        }
Exemplo n.º 9
0
        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);
            }
        }
Exemplo n.º 10
0
        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());
            }
        }
Exemplo n.º 11
0
        public static void CantWriteNegativeCount()
        {
            var sw = new ArrayPooledTextWriter();

            Assert.Throws <ArgumentOutOfRangeException>(() => sw.Write(new char[0], 0, -1));
        }
Exemplo n.º 12
0
        public static void CantWriteNullArray()
        {
            var sw = new ArrayPooledTextWriter();

            Assert.Throws <ArgumentNullException>(() => sw.Write(null, 0, 0));
        }
Exemplo n.º 13
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"); });
 }