Esempio n. 1
0
        static void Main(string[] args)
        {
            APIService api = APIService.getApiService();

            //1. create a request object
            //2. serialize object to xml
            //3. send xml as byte array to api
            api.SendRequest(SerializableHelper.SerializeRequestToXml(
                                CreateRequest(
                                    "EZE",
                                    DateTime.Now.ToString("dd/MM/yyyy"),
                                    DateTime.Now.ToString("h:mm:ss tt"),
                                    332526,
                                    "630000000000",
                                    "25")));

            Console.ReadKey();
        }
Esempio n. 2
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());
        }