Ejemplo n.º 1
0
        public void ShouldBeAbleToConvertStreamContentIntoXElementContent()
        {
            //Arrange
            var ms = new MemoryStream();
            var sr = new StreamWriter(ms);
            sr.Write("<Hello>World</Hello>");
            sr.Flush();
            ms.Position = 0;
            var content = new StreamContent(ms);
            //Act
            var xElement = new XElementContent(content);
            var result = xElement.ReadAsStringAsync().Result;

            //Assert
            Assert.IsNotNull(xElement);
            Assert.AreEqual(@"<?xml version=""1.0"" encoding=""utf-8""?>
            <Hello>World</Hello>", result);
        }
Ejemplo n.º 2
0
        public void ShouldBeAbleToConvertStreamContentIntoXElementContent()
        {
            //Arrange
            var ms = new MemoryStream();
            var sr = new StreamWriter(ms);
            sr.Write("<Hello>World</Hello>");
            sr.Flush();
            ms.Position = 0;
            var content = new StreamContent(ms);
            //Act
            var xElement = new XElementContent(content);
            var result = xElement.ReadAsStringAsync().Result;

            //Assert
            Assert.IsNotNull(xElement);
            Assert.IsTrue(result.EndsWith("<Hello>World</Hello>"));
        }