Exemple #1
0
        protected override void DoTestRoundTrip(BluetoothEndPoint obj)
        {
            XmlSerializer szr = new XmlSerializer(obj.GetType());
            StringWriter  wtr = new StringWriter();

            szr.Serialize(wtr, obj);
            //
            StringReader      rdr  = new StringReader(wtr.ToString());
            BluetoothEndPoint back = (BluetoothEndPoint)szr.Deserialize(rdr);

            Assert.AreEqual(obj, back, "Equals");
            Assert.AreEqual(obj.Address, back.Address, "Address");
            Assert.AreEqual(obj.Address.ToString("C"), back.Address.ToString("C"), "Address.ToString(\"C\")");
            Assert.AreEqual(obj.Service, back.Service, "Service");
            Assert.AreEqual(obj.Port, back.Port, "Port");
        }
Exemple #2
0
        public void OneFormat()
        {
            BluetoothEndPoint obj = new BluetoothEndPoint(
                BluetoothAddress.Parse("001122334455"), BluetoothService.SerialPort);
            //
            XmlSerializer szr = new XmlSerializer(obj.GetType());
            StringWriter  wtr = new StringWriter();

            szr.Serialize(wtr, obj);
            // SZ Format
            const String NewLine   = "\r\n";
            const String XmlHeader = "<?xml version=\"1.0\" encoding=\"utf-16\"?>" + NewLine;
            String       xmlData
                = XmlHeader
                  + "<BluetoothEndPoint xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" + NewLine
                  + "  <Address>001122334455</Address>" + NewLine
                  + "  <Service>00001101-0000-1000-8000-00805f9b34fb</Service>" + NewLine
                  + "  <Port>-1</Port>" + NewLine
                  + "</BluetoothEndPoint>"
                ;

            Assert.AreEqual(xmlData, wtr.ToString(), "Equals");
        }