Пример #1
0
        public void Create_Byte_Array_From_XML()
        {
            //add reference to APIService
            APIService api = APIService.getApiService();
            //create a request object for testing
            Request r = new Request();

            r.Header.Identifier  = "EZE";
            r.Header.MessageDate = "14/03/2017";
            r.Header.MessageTime = "10:54:25 PM";
            r.Body.MessageID     = 332526;
            r.Body.PhoneNumber   = "630000000000";
            r.Body.Amount        = "25";

            string expected = "<?xml version=\"1.0\"?><Request xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><Header><Identifier>EZE</Identifier><MessageDate>14/03/2017</MessageDate><MessageTime>10:54:25 PM</MessageTime></Header><Body><MessageID>332526</MessageID><PhoneNumber>630000000000</PhoneNumber><Amount>25</Amount></Body></Request>";


            XmlDocument doc = SerializableHelper.SerializeRequestToXml(r);

            string actual = System.Text.Encoding.Default.GetString(api.ConvertByteArrayFromXml(doc));

            Assert.AreEqual(expected.ToString(), actual.ToString());
        }
Пример #2
0
        public void Create_Byte_Array_From_XML()
        {
            HelperClass s = new HelperClass();
            //add reference to APIService
            APIService api = APIService.getApiService();
            //create a request object for testing
            Request r = new Request();

            r.header.identifier  = "EZE";
            r.header.messageDate = "14/03/2017";
            r.header.messageTime = "10:54:25 PM";
            r.body.messageID     = 332526;
            r.body.phoneNumber   = "630000000000";
            r.body.amount        = "25";

            string expected = "<?xml version=\"1.0\"?><Request xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><header><identifier>EZE</identifier><messageDate>14/03/2017</messageDate><messageTime>10:54:25 PM</messageTime></header><body><messageID>332526</messageID><phoneNumber>630000000000</phoneNumber><amount>25</amount></body></Request>";


            XmlDocument doc = s.serializeRequestObject(r);

            string actual = System.Text.Encoding.Default.GetString(api.ConvertByteArrayFromXml(doc));

            Assert.AreEqual(expected.ToString(), actual.ToString());
        }