コード例 #1
0
        public void GZipSerializer_Serialize_Smaller_Then_Just_Serialize()
        {
            SerializeTestClass serializeTestClass = new SerializeTestClass
            {
                IntProp      = 5,
                StringProp   = @"Overly long unformatted statements present fellow editors a dilemma: spend excessive time parsing out what a writer means or being mildly rude in not actually reading what is written. 
                               It is more collegial and collaborative to take an extra few moments to distill one's thoughts into bite size pieces.
                               Traditionally, the phrase too long; didn't read (abbreviated tl;dr or simply tldr) has been used on the Internet as a reply to an excessively long statement. 
                               It indicates that the reader did not actually read the statement due to its undue length.[2] This essay especially considers the term as used in Wikipedia discussions, 
                               and examines methods of fixing the problem when found in article content.
                               As a label, it is sometimes used as a tactic to thwart the kinds of discussion which are essential in collaborative editing. 
                               On the other hand, tl;dr may represent a shorthand acknowledgement of time saved by skimming over or skipping repetitive or poorly written material. 
                               Thus, the implication of the symbol can range from a brilliant and informative disquisition being given up due to a reader's lack of endurance, interest, or intelligence,
                               to a clustered composition of such utter failure to communicate that it has left the capable reader with a headache; judging this range is very subjective.",
                DateTimeProp = DateTime.Today
            };

            GZipSerializer sut = new GZipSerializer();

            byte[] serializedWithGZipSerializer = sut.Serialize(serializeTestClass);
            byte[] justSerialized = SerializeToByteArray(serializeTestClass);

            long sizeOfGzipped    = GetSize(serializedWithGZipSerializer);
            long sizeOfSerialized = GetSize(justSerialized);

            Debug.WriteLine(string.Format("Size of zipped: {0} bytes", sizeOfGzipped));
            Debug.WriteLine(string.Format("Size of raw:    {0} bytes", sizeOfSerialized));

            Assert.IsNotNull(serializedWithGZipSerializer);
            Assert.IsNotNull(justSerialized);
            Assert.IsTrue(sizeOfGzipped < sizeOfSerialized);
        }
コード例 #2
0
        public void GZipSerializer_Serialize_Smaller_Then_Just_Serialize()
        {
            SerializeTestClass serializeTestClass = new SerializeTestClass
            {
                IntProp = 5,
                StringProp = @"Overly long unformatted statements present fellow editors a dilemma: spend excessive time parsing out what a writer means or being mildly rude in not actually reading what is written. 
                               It is more collegial and collaborative to take an extra few moments to distill one's thoughts into bite size pieces.
                               Traditionally, the phrase too long; didn't read (abbreviated tl;dr or simply tldr) has been used on the Internet as a reply to an excessively long statement. 
                               It indicates that the reader did not actually read the statement due to its undue length.[2] This essay especially considers the term as used in Wikipedia discussions, 
                               and examines methods of fixing the problem when found in article content.
                               As a label, it is sometimes used as a tactic to thwart the kinds of discussion which are essential in collaborative editing. 
                               On the other hand, tl;dr may represent a shorthand acknowledgement of time saved by skimming over or skipping repetitive or poorly written material. 
                               Thus, the implication of the symbol can range from a brilliant and informative disquisition being given up due to a reader's lack of endurance, interest, or intelligence,
                               to a clustered composition of such utter failure to communicate that it has left the capable reader with a headache; judging this range is very subjective.",
                DateTimeProp = DateTime.Today
            };

            GZipSerializer sut = new GZipSerializer();

            byte[] serializedWithGZipSerializer = sut.Serialize(serializeTestClass);
            byte[] justSerialized = SerializeToByteArray(serializeTestClass);

            long sizeOfGzipped = GetSize(serializedWithGZipSerializer);
            long sizeOfSerialized = GetSize(justSerialized);

            Debug.WriteLine(string.Format("Size of zipped: {0} bytes", sizeOfGzipped));
            Debug.WriteLine(string.Format("Size of raw:    {0} bytes", sizeOfSerialized));

            Assert.IsNotNull(serializedWithGZipSerializer);
            Assert.IsNotNull(justSerialized);
            Assert.IsTrue(sizeOfGzipped < sizeOfSerialized);
        }
コード例 #3
0
        public void GZipSerializer_Serialize_Deserialize_Returns_Same_Object()
        {
            SerializeTestClass serializeTestClass = new SerializeTestClass
            {
                IntProp      = 5,
                StringProp   = "Test",
                DateTimeProp = DateTime.Today
            };

            GZipSerializer sut = new GZipSerializer();

            byte[]             serializedClass = sut.Serialize(serializeTestClass);
            SerializeTestClass result          = sut.Deserialize(serializedClass) as SerializeTestClass;

            Assert.IsNotNull(serializedClass);
            Assert.IsNotNull(result);
            Assert.AreEqual(serializeTestClass.DateTimeProp, result.DateTimeProp);
            Assert.AreEqual(serializeTestClass.IntProp, result.IntProp);
            Assert.AreEqual(serializeTestClass.StringProp, result.StringProp);
        }
コード例 #4
0
        public void GZipSerializer_Serialize_Deserialize_Returns_Same_Object()
        {
            SerializeTestClass serializeTestClass = new SerializeTestClass
            {
                IntProp = 5,
                StringProp = "Test",
                DateTimeProp = DateTime.Today
            };

            GZipSerializer sut = new GZipSerializer();

            byte[] serializedClass = sut.Serialize(serializeTestClass);
            SerializeTestClass result = sut.Deserialize<SerializeTestClass>(serializedClass);

            Assert.IsNotNull(serializedClass);
            Assert.IsNotNull(result);
            Assert.AreEqual(serializeTestClass.DateTimeProp, result.DateTimeProp);
            Assert.AreEqual(serializeTestClass.IntProp, result.IntProp);
            Assert.AreEqual(serializeTestClass.StringProp, result.StringProp);
        }