コード例 #1
0
        public void SerializableJson_ObjectToContainerToObject_ExplicitAlgorithm()
        {
            Support.MyDataSet original = MakeMyDataSet();
            int    setCount            = original.coll.Count;
            string password            = "******";
            string salt = "JustAsEasy";

            SymmetricAlgorithm algorithm = new DESCryptoServiceProvider();

            string transitContent = ObjectXMLSerializer <Support.MyDataSet> .CreateTransitContainerForObject(original, password, salt, algorithm);

            Support.MyDataSet result = ObjectXMLSerializer <Support.MyDataSet> .CreateObjectFromTransitContainer(transitContent, password, salt, algorithm);

            Assert.AreEqual(result.s1, original.s1, "s1 not same");
            Assert.AreEqual(result.i16, original.i16, "i16 not same");
            Assert.AreEqual(result.i32, original.i32, "i32 not same");
            Assert.AreEqual(result.i64, original.i64, "i64 not same");
            Assert.AreEqual(result.Timestamp, original.Timestamp, "Timestamp not same");
            Assert.AreEqual(result.coll.Count, setCount, "coll.Count not " + setCount.ToString());
            Assert.AreEqual(result.coll.Count, original.coll.Count, "coll.Count not same");
            for (int index = 0; index < setCount; index++)
            {
                Assert.AreEqual(result.coll[index], original.coll[index], "coll[] not same at index " + index.ToString());
            }
        }
コード例 #2
0
        public void SerializableJson_ObjectToContainerToObject_ImplicitAlgorithm()
        {
            Support.MyDataSet original = MakeMyDataSet();
            int    setCount            = original.coll.Count;
            string password            = "******";
            string salt = "JustAsEasy";

            string rawContent = ObjectXMLSerializer <Support.MyDataSet> .CreateDocumentFormat(original);

            //int rawContentLength = rawContent.Length;

            string transitContent = ObjectXMLSerializer <Support.MyDataSet> .CreateTransitContainerForObject(original, password, salt);

            //int transitContentLength = transitContent.Length;

            Support.MyDataSet result = ObjectXMLSerializer <Support.MyDataSet> .CreateObjectFromTransitContainer(transitContent, password, salt);

            Assert.AreEqual(result.s1, original.s1, "s1 not same");
            Assert.AreEqual(result.i16, original.i16, "i16 not same");
            Assert.AreEqual(result.i32, original.i32, "i32 not same");
            Assert.AreEqual(result.i64, original.i64, "i64 not same");
            Assert.AreEqual(result.Timestamp, original.Timestamp, "Timestamp not same");
            Assert.AreEqual(result.coll.Count, setCount, "coll.Count not " + setCount.ToString());
            Assert.AreEqual(result.coll.Count, original.coll.Count, "coll.Count not same");
            for (int index = 0; index < setCount; index++)
            {
                Assert.AreEqual(result.coll[index], original.coll[index], "coll[] not same at index " + index.ToString());
            }
        }