public void ReadMessage()
        {
            using (var ms = File.OpenRead(TestResourceHelper.GetFullPathOfResource("Test/Resources/binary-message.raw"))) {
                var     session = new XmlBinaryReaderSession();
                byte [] rsbuf   = new BinaryFrameSupportReader(ms).ReadSizedChunk();
                int     count   = 0;
                using (var rms = new MemoryStream(rsbuf, 0, rsbuf.Length)) {
                    var rbr = new BinaryReader(rms, Encoding.UTF8);
                    while (rms.Position < rms.Length)
                    {
                        session.Add(count++, rbr.ReadString());
                    }
                }
                var xr = XmlDictionaryReader.CreateBinaryReader(ms, BinaryFrameSupportReader.soap_dictionary, new XmlDictionaryReaderQuotas(), session);

                string soapNS  = "http://www.w3.org/2003/05/soap-envelope";
                string addrNS  = "http://www.w3.org/2005/08/addressing";
                string xmlnsNS = "http://www.w3.org/2000/xmlns/";
                string peerNS  = "http://schemas.microsoft.com/net/2006/05/peer";

                xr.MoveToContent();
                AssertNode(xr, 0, XmlNodeType.Element, "s", "Envelope", soapNS, String.Empty, "#1");
                Assert.AreEqual(2, xr.AttributeCount, "#1-1-1");
                Assert.IsTrue(xr.MoveToAttribute("s", xmlnsNS), "#1-2");
                AssertNode(xr, 1, XmlNodeType.Attribute, "xmlns", "s", xmlnsNS, soapNS, "#2");
                Assert.IsTrue(xr.MoveToAttribute("a", xmlnsNS), "#2-2");
                AssertNode(xr, 1, XmlNodeType.Attribute, "xmlns", "a", xmlnsNS, addrNS, "#3");
                Assert.IsTrue(xr.Read(), "#3-2");
                AssertNode(xr, 1, XmlNodeType.Element, "s", "Header", soapNS, String.Empty, "#4");
                Assert.IsTrue(xr.Read(), "#4-2");
                AssertNode(xr, 2, XmlNodeType.Element, "a", "Action", addrNS, String.Empty, "#5");
                Assert.IsTrue(xr.MoveToAttribute("mustUnderstand", soapNS), "#5-2");
                AssertNode(xr, 3, XmlNodeType.Attribute, "s", "mustUnderstand", soapNS, "1", "#6");
                Assert.IsTrue(xr.Read(), "#6-2");
                AssertNode(xr, 3, XmlNodeType.Text, "", "", "", "http://schemas.microsoft.com/net/2006/05/peer/resolver/Resolve", "#7");
                Assert.IsTrue(xr.Read(), "#7-2");
                AssertNode(xr, 2, XmlNodeType.EndElement, "a", "Action", addrNS, String.Empty, "#8");
                Assert.IsTrue(xr.Read(), "#8-2");
                AssertNode(xr, 2, XmlNodeType.Element, "a", "MessageID", addrNS, String.Empty, "#9");
                Assert.IsTrue(xr.Read(), "#9-2");
                Assert.AreEqual(XmlNodeType.Text, xr.NodeType, "#10");
                Assert.IsTrue(xr.Read(), "#10-2");
                AssertNode(xr, 2, XmlNodeType.EndElement, "a", "MessageID", addrNS, String.Empty, "#11");
                Assert.IsTrue(xr.Read(), "#11-2"); // -> a:ReplyTo
                AssertNode(xr, 2, XmlNodeType.Element, "a", "ReplyTo", addrNS, String.Empty, "#12");
                xr.Skip();                         // -> a:To
                AssertNode(xr, 2, XmlNodeType.Element, "a", "To", addrNS, String.Empty, "#13");
                xr.Skip();                         // -> /s:Header
                AssertNode(xr, 1, XmlNodeType.EndElement, "s", "Header", soapNS, String.Empty, "#14");

                Assert.IsTrue(xr.Read(), "#14-2");
                AssertNode(xr, 1, XmlNodeType.Element, "s", "Body", soapNS, String.Empty, "#15");
                Assert.IsTrue(xr.Read(), "#15-2");
                AssertNode(xr, 2, XmlNodeType.Element, "", "Resolve", peerNS, String.Empty, "#16");
                Assert.IsTrue(xr.MoveToAttribute("xmlns"), "#16-2");
                AssertNode(xr, 3, XmlNodeType.Attribute, "", "xmlns", xmlnsNS, peerNS, "#17");
                Assert.IsTrue(xr.Read(), "#17-2");
                AssertNode(xr, 3, XmlNodeType.Element, "", "ClientId", peerNS, String.Empty, "#18");

/*
 *                              while (!xr.EOF) {
 *                                      xr.Read ();
 *                                      Console.WriteLine ("{0}: {1}:{2} {3} {4}", xr.NodeType, xr.Prefix, xr.LocalName, xr.NamespaceURI, xr.Value);
 *                                      for (int i = 0; i < xr.AttributeCount; i++) {
 *                                              xr.MoveToAttribute (i);
 *                                              Console.WriteLine ("  Attribute: {0}:{1} {2} {3}", xr.Prefix, xr.LocalName, xr.NamespaceURI, xr.Value);
 *                                      }
 *                              }
 */
            }
        }
		public void ReadMessage ()
		{
			using (var ms = File.OpenRead ("Test/System.ServiceModel.Channels/binary-message.raw")) {

				var session = new XmlBinaryReaderSession ();
				byte [] rsbuf = new BinaryFrameSupportReader (ms).ReadSizedChunk ();
				int count = 0;
				using (var rms = new MemoryStream (rsbuf, 0, rsbuf.Length)) {
					var rbr = new BinaryReader (rms, Encoding.UTF8);
					while (rms.Position < rms.Length)
						session.Add (count++, rbr.ReadString ());
				}
				var xr = XmlDictionaryReader.CreateBinaryReader (ms, BinaryFrameSupportReader.soap_dictionary, new XmlDictionaryReaderQuotas (), session);

				string soapNS = "http://www.w3.org/2003/05/soap-envelope";
				string addrNS = "http://www.w3.org/2005/08/addressing";
				string xmlnsNS = "http://www.w3.org/2000/xmlns/";
				string peerNS = "http://schemas.microsoft.com/net/2006/05/peer";

				xr.MoveToContent ();
				AssertNode (xr, 0, XmlNodeType.Element, "s", "Envelope", soapNS, String.Empty, "#1");
				Assert.AreEqual (2, xr.AttributeCount, "#1-1-1");
				Assert.IsTrue (xr.MoveToAttribute ("s", xmlnsNS), "#1-2");
				AssertNode (xr, 1, XmlNodeType.Attribute, "xmlns", "s", xmlnsNS, soapNS, "#2");
				Assert.IsTrue (xr.MoveToAttribute ("a", xmlnsNS), "#2-2");
				AssertNode (xr, 1, XmlNodeType.Attribute, "xmlns", "a", xmlnsNS, addrNS, "#3");
				Assert.IsTrue (xr.Read (), "#3-2");
				AssertNode (xr, 1, XmlNodeType.Element, "s", "Header", soapNS, String.Empty, "#4");
				Assert.IsTrue (xr.Read (), "#4-2");
				AssertNode (xr, 2, XmlNodeType.Element, "a", "Action", addrNS, String.Empty, "#5");
				Assert.IsTrue (xr.MoveToAttribute ("mustUnderstand", soapNS), "#5-2");
				AssertNode (xr, 3, XmlNodeType.Attribute, "s", "mustUnderstand", soapNS, "1", "#6");
				Assert.IsTrue (xr.Read (), "#6-2");
				AssertNode (xr, 3, XmlNodeType.Text, "", "", "", "http://schemas.microsoft.com/net/2006/05/peer/resolver/Resolve", "#7");
				Assert.IsTrue (xr.Read (), "#7-2");
				AssertNode (xr, 2, XmlNodeType.EndElement, "a", "Action", addrNS, String.Empty, "#8");
				Assert.IsTrue (xr.Read (), "#8-2");
				AssertNode (xr, 2, XmlNodeType.Element, "a", "MessageID", addrNS, String.Empty, "#9");
				Assert.IsTrue (xr.Read (), "#9-2");
				Assert.AreEqual (XmlNodeType.Text, xr.NodeType, "#10");
				Assert.IsTrue (xr.Read (), "#10-2");
				AssertNode (xr, 2, XmlNodeType.EndElement, "a", "MessageID", addrNS, String.Empty, "#11");
				Assert.IsTrue (xr.Read (), "#11-2"); // -> a:ReplyTo
				AssertNode (xr, 2, XmlNodeType.Element, "a", "ReplyTo", addrNS, String.Empty, "#12");
				xr.Skip (); // -> a:To
				AssertNode (xr, 2, XmlNodeType.Element, "a", "To", addrNS, String.Empty, "#13");
				xr.Skip (); // -> /s:Header
				AssertNode (xr, 1, XmlNodeType.EndElement, "s", "Header", soapNS, String.Empty, "#14");

				Assert.IsTrue (xr.Read (), "#14-2");
				AssertNode (xr, 1, XmlNodeType.Element, "s", "Body", soapNS, String.Empty, "#15");
				Assert.IsTrue (xr.Read (), "#15-2");
				AssertNode (xr, 2, XmlNodeType.Element, "", "Resolve", peerNS, String.Empty, "#16");
				Assert.IsTrue (xr.MoveToAttribute ("xmlns"), "#16-2");
				AssertNode (xr, 3, XmlNodeType.Attribute, "", "xmlns", xmlnsNS, peerNS, "#17");
				Assert.IsTrue (xr.Read (), "#17-2");
				AssertNode (xr, 3, XmlNodeType.Element, "", "ClientId", peerNS, String.Empty, "#18");
/*
				while (!xr.EOF) {
					xr.Read ();
					Console.WriteLine ("{0}: {1}:{2} {3} {4}", xr.NodeType, xr.Prefix, xr.LocalName, xr.NamespaceURI, xr.Value);
					for (int i = 0; i < xr.AttributeCount; i++) {
						xr.MoveToAttribute (i);
						Console.WriteLine ("  Attribute: {0}:{1} {2} {3}", xr.Prefix, xr.LocalName, xr.NamespaceURI, xr.Value);
					}
				}
*/
			}
		}