Exemple #1
0
 public void TestInvalidData()
 {
     XmlDecoder decoder = new XmlDecoder();
     MemoryStream stream = new MemoryStream();
     byte[] bytes = Encoding.ASCII.GetBytes(@"<user lastname=""gauffin""><firstname>jonas</firstname>");
     stream.Write(bytes, 0, bytes.Length);
     stream.Seek(0, SeekOrigin.Begin);
     Assert.Throws(typeof (InvalidDataException), delegate
                                                      {
                                                          decoder.Decode(stream, "text/xml",
                                                                         Encoding.ASCII);
                                                      });
 }
Exemple #2
0
        public void Test()
        {
            XmlDecoder decoder = new XmlDecoder();
            Assert.True(decoder.CanParse("text/xml"));
            Assert.False(decoder.CanParse("text/plain"));
            Assert.False(decoder.CanParse("xml"));
            Assert.False(decoder.CanParse("text"));
            Assert.False(decoder.CanParse(null));

            MemoryStream stream = new MemoryStream();
            byte[] bytes = Encoding.ASCII.GetBytes(@"<user lastname=""gauffin""><firstname>jonas</firstname></user>");
            stream.Write(bytes, 0, bytes.Length);
            stream.Seek(0, SeekOrigin.Begin);

            HttpInput input = decoder.Decode(stream, "text/xml", Encoding.ASCII);
            Assert.Equal("gauffin", input["user"]["lastname"].Value);
            Assert.Equal("jonas", input["user"]["firstname"].Value);
            Assert.Null(input["unknow"].Value);
            Assert.Equal(HttpInputItem.Empty, input["unknown"]);
        }
Exemple #3
0
 public void TestNull2()
 {
     XmlDecoder decoder = new XmlDecoder();
     decoder.Decode(null, null, null);
 }
Exemple #4
0
 public void TestNull()
 {
     XmlDecoder decoder = new XmlDecoder();
     Assert.Null(decoder.Decode(new MemoryStream(), "text/xml", Encoding.ASCII));
 }