Ejemplo n.º 1
0
        public void CloneInParallel()
        {
            ObjectCloner.ClearTypeCache(); // empty the Type cache to start from a fresh state.

            for (int i = 0; i < 100; i++)
            {
                Parallel.For(0,
                             1000,
                             k =>
                {
                    var instance = new ClassWithIEnumerable <int> {
                        Items = new List <int> {
                            1, 1, 2, 3
                        }.Distinct()
                    };

                    var clonedValue = Duplicate(instance);

                    Assert.Equal(instance.Items.Count(),
                                 clonedValue.Items.Count());
                    Assert.Equal(instance.Items.ToList(),
                                 clonedValue.Items.ToList());
                });
            }
        }