Exemple #1
0
        public void Can_serialize_and_deserialize_CustomValues()
        {
            //checks if conversations are valid
            //null into ""
            //integral into string
            //no changes within special characters like < >
            ProcessPaymentRequest processPaymentRequest = new ProcessPaymentRequest();

            processPaymentRequest.CustomValues.Add("key01", "value01");
            processPaymentRequest.CustomValues.Add("key02", null);
            processPaymentRequest.CustomValues.Add("key03", 331233);
            processPaymentRequest.CustomValues.Add("<key 04>", "<value 01>");

            string serializedXML = processPaymentRequest.SerializeCustomValues();
            Dictionary <string, object> deserialized = processPaymentRequest.DeserializeCustomValues(serializedXML);

            Assert.IsNotNull(deserialized);
            Assert.AreEqual(4, deserialized.Count);

            Assert.IsTrue(deserialized.ContainsKey("key01"));
            Assert.AreEqual("value01", deserialized["key01"]);

            Assert.IsTrue(deserialized.ContainsKey("key02"));
            Assert.AreEqual("", deserialized["key02"]);

            Assert.IsTrue(deserialized.ContainsKey("key03"));
            Assert.AreEqual("331233", deserialized["key03"]);

            Assert.IsTrue(deserialized.ContainsKey("<key 04>"));
            Assert.AreEqual("<value 01>", deserialized["<key 04>"]);
        }
        public void Can_serialize_and_deserialize_CustomValues()
        {
            var processPaymentRequest = new ProcessPaymentRequest();

            processPaymentRequest.CustomValues.Add("key1", "value1");
            processPaymentRequest.CustomValues.Add("key2", null);
            processPaymentRequest.CustomValues.Add("key3", 3);
            processPaymentRequest.CustomValues.Add("<test key4>", "<test value 4>");
            var serializedXml = processPaymentRequest.SerializeCustomValues();
            var deserialized  = processPaymentRequest.DeserializeCustomValues(serializedXml);

            deserialized.ShouldNotBeNull();
            deserialized.Count.ShouldEqual(4);

            deserialized.ContainsKey("key1").ShouldEqual(true);
            deserialized["key1"].ShouldEqual("value1");

            deserialized.ContainsKey("key2").ShouldEqual(true);
            //deserialized["key2"].ShouldEqual(null);
            deserialized["key2"].ShouldEqual("");

            deserialized.ContainsKey("key3").ShouldEqual(true);
            deserialized["key3"].ShouldEqual("3");

            deserialized.ContainsKey("<test key4>").ShouldEqual(true);
            deserialized["<test key4>"].ShouldEqual("<test value 4>");
        }
        public void Can_deserialize_null_string()
        {
            var processPaymentRequest = new ProcessPaymentRequest();
            var deserialized          = processPaymentRequest.DeserializeCustomValues(null);

            deserialized.ShouldNotBeNull();
            deserialized.Count.ShouldEqual(0);
        }
Exemple #4
0
        public void Can_deserialize_null_string()
        {
            //passsing null, shouldn't be null
            ProcessPaymentRequest       processPaymentRequest = new ProcessPaymentRequest();
            Dictionary <string, object> deserialized          = processPaymentRequest.DeserializeCustomValues(null);

            Assert.IsNotNull(deserialized);
            Assert.AreEqual(0, deserialized.Count());
        }
        public void Can_serialize_and_deserialize_empty_CustomValues()
        {
            var processPaymentRequest = new ProcessPaymentRequest();
            var serializedXml         = processPaymentRequest.SerializeCustomValues();
            var deserialized          = processPaymentRequest.DeserializeCustomValues(serializedXml);

            deserialized.ShouldNotBeNull();
            deserialized.Count.ShouldEqual(0);
        }
Exemple #6
0
        public void Can_serialize_and_deserialize_empty_CustomValues()
        {
            //passsing serialized empty object
            ProcessPaymentRequest processPaymentRequest = new ProcessPaymentRequest();
            string serializedXML = processPaymentRequest.SerializeCustomValues();
            Dictionary <string, object> deserialized = processPaymentRequest.DeserializeCustomValues(serializedXML);

            Assert.IsNotNull(deserialized);
            Assert.AreEqual(0, deserialized.Count());
        }