public void BasicSerializationProxyTest()
        {
            ProxyGenerator generator = new ProxyGenerator();
            ClassOverridingEqualsAndGetHashCode c =
                (ClassOverridingEqualsAndGetHashCode)generator.CreateClassProxy(typeof(ClassOverridingEqualsAndGetHashCode));

            c.Id   = Guid.NewGuid();
            c.Name = DateTime.Now.ToString("yyyyMMddHHmmss");

            ClassOverridingEqualsAndGetHashCode c2 = SerializeAndDeserialize <ClassOverridingEqualsAndGetHashCode>(c);

            Assert.IsNotNull(c2);
            Assert.AreEqual(c.Id, c2.Id);
            Assert.AreEqual(c.Name, c2.Name);
        }
        public void DictionaryDeserializationWithoutProxyTest()
        {
            Dictionary <ClassOverridingEqualsAndGetHashCode, string> theInstances =
                new Dictionary <ClassOverridingEqualsAndGetHashCode, string>();

            for (int i = 0; i < 50; i++)
            {
                ClassOverridingEqualsAndGetHashCode c = new ClassOverridingEqualsAndGetHashCode();
                c.Id   = Guid.NewGuid();
                c.Name = DateTime.Now.ToString("yyyyMMddHHmmss");
                theInstances.Add(c, c.Name);
            }

            Dictionary <ClassOverridingEqualsAndGetHashCode, string> theInstancesBis =
                SerializeAndDeserialize <Dictionary <ClassOverridingEqualsAndGetHashCode, string> >(theInstances);
        }
        public void NullReferenceProxyDeserializationTest()
        {
            ProxyGenerator generator = new ProxyGenerator();
            Dictionary <ClassOverridingEqualsAndGetHashCode, string> theInstances =
                new Dictionary <ClassOverridingEqualsAndGetHashCode, string>();
            ClassOverridingEqualsAndGetHashCode c =
                (ClassOverridingEqualsAndGetHashCode)generator.CreateClassProxy(typeof(ClassOverridingEqualsAndGetHashCode));

            c.Id   = Guid.NewGuid();
            c.Name = DateTime.Now.ToString("yyyyMMddHHmmss");
            theInstances.Add(c, c.Name);
            Dictionary <ClassOverridingEqualsAndGetHashCode, string> theInstancesBis =
                SerializeAndDeserialize <Dictionary <ClassOverridingEqualsAndGetHashCode, string> >(theInstances);

            Assert.IsNotNull(theInstancesBis);
            Assert.AreEqual(theInstances.Count, theInstancesBis.Count);
        }
        public void DictionaryDeserializationWithProxyTest()
        {
            ProxyGenerator generator = new ProxyGenerator();
            Dictionary <ClassOverridingEqualsAndGetHashCode, string> theInstances =
                new Dictionary <ClassOverridingEqualsAndGetHashCode, string>();

            for (int i = 0; i < 50; i++)
            {
                ClassOverridingEqualsAndGetHashCode c =
                    (ClassOverridingEqualsAndGetHashCode)generator.CreateClassProxy(typeof(ClassOverridingEqualsAndGetHashCode));
                c.Id   = Guid.NewGuid();
                c.Name = DateTime.Now.ToString("yyyyMMddHHmmss");
                theInstances.Add(c, c.Name);
            }

            Dictionary <ClassOverridingEqualsAndGetHashCode, string> theInstancesBis =
                SerializeAndDeserialize <Dictionary <ClassOverridingEqualsAndGetHashCode, string> >(theInstances);
        }
Exemplo n.º 5
0
        public void DictionaryDeserializationWithoutProxyTest()
        {
            var theInstances =
                new Dictionary <ClassOverridingEqualsAndGetHashCode, string>();

            for (var i = 0; i < 50; i++)
            {
                var c = new ClassOverridingEqualsAndGetHashCode
                {
                    Id   = Guid.NewGuid(),
                    Name = DateTime.Now.ToString("yyyyMMddHHmmss")
                };
                theInstances.Add(c, c.Name);
            }

#pragma warning disable 219
            var theInstancesBis =
                SerializeAndDeserialize(theInstances);
#pragma warning restore 219
        }