Exemple #1
0
        public void op_ToString()
        {
            const string expected = "<root />";
            var          actual   = ApplicationXml.FromString(expected).ToString();

            Assert.Equal(expected, actual);
        }
        public void op_FromString_string()
        {
            var xml = new XmlDocument();
            xml.LoadXml("<root />");

            var expected = new ApplicationXml(xml);
            var actual = ApplicationXml.FromString("<root />");

            Assert.Equal(expected, actual);
        }
        public void opImplicit_ApplicationXml_string()
        {
            var xml = new XmlDocument();
            xml.LoadXml("<root />");

            var expected = new ApplicationXml(xml);
            ApplicationXml actual = "<root />";

            Assert.Equal(expected, actual);
        }
Exemple #4
0
        public void op_FromString_string()
        {
            var xml = new XmlDocument();

            xml.LoadXml("<root />");

            var expected = new ApplicationXml(xml);
            var actual   = ApplicationXml.FromString("<root />");

            Assert.Equal(expected, actual);
        }
Exemple #5
0
        public void opImplicit_ApplicationXml_string()
        {
            var xml = new XmlDocument();

            xml.LoadXml("<root />");

            var            expected = new ApplicationXml(xml);
            ApplicationXml actual   = "<root />";

            Assert.Equal(expected, actual);
        }
Exemple #6
0
 public void op_Write_TextWriter_whenPost()
 {
     using (var stream = new MemoryStream())
     {
         using (var writer = new StreamWriter(stream))
         {
             ApplicationXml.FromString("<root />").Write(writer);
             writer.Flush();
             stream.Position = 0;
             using (var reader = new StreamReader(stream))
             {
                 Assert.Equal("<root />", reader.ReadToEnd());
             }
         }
     }
 }
Exemple #7
0
        public void op_ToContent_TextReader()
        {
            IContent body;

            using (var stream = new MemoryStream())
            {
                using (var writer = new StreamWriter(stream))
                {
                    writer.Write("<root />");
                    writer.Flush();
                    stream.Position = 0;
                    using (var reader = new StreamReader(stream))
                    {
                        body = new ApplicationXml().ToContent(reader);
                    }
                }
            }

            Assert.Equal <string>("<root />", body as ApplicationXml);
        }
Exemple #8
0
        public void op_ToContent_TextReaderEmpty()
        {
            IContent body;

            using (var stream = new MemoryStream())
            {
                using (var writer = new StreamWriter(stream))
                {
                    writer.Flush();
                    stream.Position = 0;
                    using (var reader = new StreamReader(stream))
                    {
                        body = new ApplicationXml().ToContent(reader);
                    }
                }
            }

            var expected = string.Empty;
            var actual   = body as ApplicationXml;

            Assert.Equal <string>(expected, actual);
        }
        public void op_ToContent_TextReader()
        {
            IContent body;

            using (var stream = new MemoryStream())
            {
                using (var writer = new StreamWriter(stream))
                {
                    writer.Write("<root />");
                    writer.Flush();
                    stream.Position = 0;
                    using (var reader = new StreamReader(stream))
                    {
                        body = new ApplicationXml().ToContent(reader);
                    }
                }
            }

            Assert.Equal<string>("<root />", body as ApplicationXml);
        }
        public void op_ToContent_TextReader_whenStringEmpty()
        {
            IContent body;

            using (var stream = new MemoryStream())
            {
                using (var writer = new StreamWriter(stream))
                {
                    writer.Write(string.Empty);
                    writer.Flush();
                    stream.Position = 0;
                    using (var reader = new StreamReader(stream))
                    {
                        body = new ApplicationXml().ToContent(reader);
                    }
                }
            }

            var expected = string.Empty;
            var actual = body as ApplicationXml;

            Assert.Equal<string>(expected, actual);
        }
Exemple #11
0
 public void op_FromString_stringNull()
 {
     Assert.Throws <ArgumentNullException>(() => ApplicationXml.FromString(null));
 }
Exemple #12
0
 public void op_FromString_stringEmpty()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => ApplicationXml.FromString(string.Empty));
 }