public virtual void Test()
        {
            var portableFactory = new PortableFactoryFunc(i =>
            {
                if (i == 1)
                {
                    return(new PortablePerson());
                }
                if (i == 2)
                {
                    return(new PortableAddress());
                }
                throw new ArgumentException();
            });

            var ss = new SerializationServiceBuilder()
                     .AddPortableFactory(FactoryId, portableFactory)
                     .AddDataSerializableFactory(FactoryId, new ArrayDataSerializableFactory(new Func <IIdentifiedDataSerializable>[]
            {
                () => new Address(),
                () => new Person(),
            }))
                     .Build();
            var k     = 10;
            var tasks = new Task[k];

            for (var i = 0; i < k; i++)
            {
                tasks[i] = Task.Factory.StartNew(() =>
                {
                    for (var j = 0; j < 10000; j++)
                    {
                        var key     = "key" + Rnd();
                        var dataKey = ss.ToData(key);
                        Assert.AreEqual(key, ss.ToObject <string>(dataKey));
                        var value     = 123L + Rnd();
                        var dataValue = ss.ToData(value);
                        Assert.AreEqual(value, ss.ToObject <long>(dataValue));
                        var address     = new Address("here here" + Rnd(), 13131 + Rnd());
                        var dataAddress = ss.ToData(address);
                        Assert.AreEqual(address, ss.ToObject <Address>(dataAddress));
                        var person     = new Person(13 + Rnd(), 199L + Rnd(), 56.89d, "mehmet", address);
                        var dataPerson = ss.ToData(person);
                        Assert.AreEqual(person, ss.ToObject <Person>(dataPerson));
                        var portableAddress     = new PortableAddress("there there " + Rnd(), 90909 + Rnd());
                        var dataPortableAddress = ss.ToData(portableAddress);
                        Assert.AreEqual(portableAddress, ss.ToObject <PortableAddress>(dataPortableAddress));
                        var portablePerson     = new PortablePerson(63 + Rnd(), 167L + Rnd(), "ahmet", portableAddress);
                        var dataPortablePerson = ss.ToData(portablePerson);
                        Assert.AreEqual(portablePerson, ss.ToObject <PortablePerson>(dataPortablePerson));
                    }
                });
            }
            Task.WaitAll(tasks, new TimeSpan(0, 0, 0, 30));
        }
        public virtual void Test()
        {
            var portableFactory = new PortableFactoryFunc(i =>
            {
                if (i == 1) return new PortablePerson();
                if (i == 2) return new PortableAddress();
                throw new ArgumentException();
            });

            var ss = new SerializationServiceBuilder()
                .AddPortableFactory(FactoryId, portableFactory)
                .AddDataSerializableFactory(FactoryId, new ArrayDataSerializableFactory(new Func<IIdentifiedDataSerializable>[]
                {
                    () => new Address(),
                    () => new Person(),
                }))
                .Build();
            var k = 10;
            var tasks = new Task[k];
            for (var i = 0; i < k; i++)
            {
                tasks[i] = Task.Factory.StartNew(() =>
                {
                    for (var j = 0; j < 10000; j++)
                    {
                        var key = "key" + Rnd();
                        var dataKey = ss.ToData(key);
                        Assert.AreEqual(key, ss.ToObject<string>(dataKey));
                        var value = 123L + Rnd();
                        var dataValue = ss.ToData(value);
                        Assert.AreEqual(value, ss.ToObject<long>(dataValue));
                        var address = new Address("here here" + Rnd(), 13131 + Rnd());
                        var dataAddress = ss.ToData(address);
                        Assert.AreEqual(address, ss.ToObject<Address>(dataAddress));
                        var person = new Person(13 + Rnd(), 199L + Rnd(), 56.89d, "mehmet", address);
                        var dataPerson = ss.ToData(person);
                        Assert.AreEqual(person, ss.ToObject<Person>(dataPerson));
                        var portableAddress = new PortableAddress("there there " + Rnd(), 90909 + Rnd());
                        var dataPortableAddress = ss.ToData(portableAddress);
                        Assert.AreEqual(portableAddress, ss.ToObject<PortableAddress>(dataPortableAddress));
                        var portablePerson = new PortablePerson(63 + Rnd(), 167L + Rnd(), "ahmet", portableAddress);
                        var dataPortablePerson = ss.ToData(portablePerson);
                        Assert.AreEqual(portablePerson, ss.ToObject<PortablePerson>(dataPortablePerson));
                    }
                });
            }
            Task.WaitAll(tasks, new TimeSpan(0, 0, 0, 30));
        }