public void Clone <T>(CloneArguments <T> args) { args.Context = new Dictionary <object, object>(16, ReferenceEqualsComparer.Instance); CopyContext c = new CopyContext(args.Context); args.Target = Cloner <T> .Get(args.Source, c); }
protected override void AfterJaggedArray2dOfSameInstance( CloneArguments <SimpleStruct?[][]> args) { base.AfterJaggedArray2dOfSameInstance(args); Assert.Single(args.Context.Keys.OfType <SimpleStruct?[][]>()); Assert.Equal(args.Context.Keys.OfType <SimpleStruct?[]>().Count(), GetItemCount(args.Target[0])); }
protected override void AfterArrayOfObjectsDiffInstance( CloneArguments <object[]> args) { base.AfterArrayOfObjectsDiffInstance(args); var count = (args.Target.Length * 2) + 1; Assert.Equal(count, args.Context.Count); }
protected override void AfterArrayOfDiffInstance( CloneArguments <DoubleSimpleClass[]> args) { base.AfterArrayOfDiffInstance(args); var count = (args.Target.Length * 2) + 1; Assert.Equal(count, args.Context.Count); }
protected override void AfterListOfObjectDiffInstance( CloneArguments <List <object> > args) { base.AfterListOfObjectDiffInstance(args); var count = (args.Target.Count * 2) + 1; Assert.Equal(count, args.Context.Count); }
protected override void AfterListOfDiffInstance( CloneArguments <List <DoubleSimpleClass> > args) { base.AfterListOfDiffInstance(args); var count = (args.Target.Count * 2) + 1; Assert.Equal(count, args.Context.Count); }
protected override void AfterMultiDimArrayRank3OfDiffInstance( CloneArguments <SimpleClass[, , ]> args) { base.AfterMultiDimArrayRank3OfDiffInstance(args); var count = (args.Target.GetLength(0) * args.Target.GetLength(1) * args.Target.GetLength(2)) + 1; Assert.Equal(count, args.Context.Count); }
protected override void AfterJaggedArray2dOfDiffInstance( CloneArguments <DoubleSimpleClass[][]> args) { base.AfterJaggedArray2dOfDiffInstance(args); var itemCount = args.Target.Select(x => x.Length).Sum(); var count = 1 + args.Target.Length + (itemCount * 2); Assert.Equal(count, args.Context.Count); }
protected virtual void AfterArrayOfObjectsSameInstance( CloneArguments <object[]> args) { Assert.NotSame(args.Source, args.Target); Assert.Equal(args.Source.Length, args.Target.Length); for (int i = 0; i < args.Target.Length; i++) { Assert.Equal((T)args.Source[i], (T)args.Target[i], _generator.Comparer); Assert.True(AreSame((T)args.Target[0], (T)args.Target[i])); } }
protected virtual void AfterArrayOfDiffInstance( CloneArguments <T[]> args) { Assert.NotSame(args.Source, args.Target); Assert.Equal(args.Source.Length, args.Target.Length); for (int i = 0; i < args.Target.Length; i++) { Assert.Equal(args.Source[i], args.Target[i], _generator.Comparer); if (i == 0) { continue; } Assert.True(AreNotSame(args.Target[0], args.Target[i])); } }
protected override void AfterSingleInstance( CloneArguments <SimpleStruct?> args) { base.AfterSingleInstance(args); Assert.Equal(0, args.Context.Count); }
protected override void AfterDictionarySameInstance( CloneArguments <Dictionary <SimpleStruct?, SimpleStruct?> > args) { base.AfterDictionarySameInstance(args); Assert.Equal(1, args.Context.Count); }
protected override void AfterArrayOfObjectsDiffInstance( CloneArguments <object[]> args) { base.AfterArrayOfObjectsDiffInstance(args); Assert.Equal(1, args.Context.Count); }
protected override void AfterKeyValuePairSame( CloneArguments <KeyValuePair <SimpleStruct?, SimpleStruct?> > args) { base.AfterKeyValuePairSame(args); Assert.Equal(0, args.Context.Count); }
protected override void AfterTupleDiffInstance( CloneArguments <Tuple <SimpleStruct?, SimpleStruct?> > args) { base.AfterTupleDiffInstance(args); Assert.Equal(1, args.Context.Count); }
protected override void AfterJaggedArray2dOfSameInstance( CloneArguments <SimpleClass[][]> args) { base.AfterJaggedArray2dOfSameInstance(args); Assert.Equal(GetItemCount(args.Target[0]) + 2, args.Context.Count); }
protected override void AfterListOfSameInstance( CloneArguments <List <SimpleStruct?> > args) { base.AfterListOfSameInstance(args); Assert.Equal(1, args.Context.Count); }
protected override void AfterDefaultInstance( CloneArguments <int> args) { base.AfterDefaultInstance(args); Assert.Equal(0, args.Context.Count); }
protected override void AfterArrayRank3OfSameInstance( CloneArguments <int[, , ]> args) { base.AfterArrayRank3OfSameInstance(args); Assert.Equal(1, args.Context.Count); }
protected override void AfterArrayOfDiffInstance( CloneArguments <SimpleClass[]> args) { base.AfterArrayOfDiffInstance(args); Assert.Equal(args.Target.Length + 1, args.Context.Count); }
protected override void AfterDictionaryDiffInstance( CloneArguments <Dictionary <int, int> > args) { base.AfterDictionaryDiffInstance(args); Assert.Equal(1, args.Context.Count); }
protected override void AfterArrayOfDefaultInstance( CloneArguments <SimpleStruct?[]> args) { base.AfterArrayOfDefaultInstance(args); Assert.Equal(1, args.Context.Count); }
protected override void AfterTupleSameInstance( CloneArguments <Tuple <SimpleClass, SimpleClass> > args) { base.AfterTupleSameInstance(args); Assert.Equal(2, args.Context.Count); }
protected override void AfterMultiDimArrayRank2OfSameInstance( CloneArguments <SimpleClass[, ]> args) { base.AfterMultiDimArrayRank2OfSameInstance(args); Assert.Equal(2, args.Context.Count); }
protected override void AfterJaggedArray2dOfDiffInstance( CloneArguments <SimpleStruct?[][]> args) { base.AfterJaggedArray2dOfDiffInstance(args); Assert.Equal(args.Target.Length + 1, args.Context.Count); }
protected override void AfterListOfObjectSameInstance( CloneArguments <List <object> > args) { base.AfterListOfObjectSameInstance(args); Assert.Equal(1, args.Context.Count); }
protected override void AfterKeyValuePairDiff( CloneArguments <KeyValuePair <int, int> > args) { base.AfterKeyValuePairDiff(args); Assert.Equal(0, args.Context.Count); }
protected override void AfterDictionarySameInstance( CloneArguments <Dictionary <SimpleClass, SimpleClass> > args) { base.AfterDictionarySameInstance(args); Assert.Equal(args.Target.Keys.Count + 1, args.Context.Count); }
protected override void AfterMultiDimArrayRank3OfDiffInstance( CloneArguments <SimpleStruct?[, , ]> args) { base.AfterMultiDimArrayRank3OfDiffInstance(args); Assert.Equal(1, args.Context.Count); }
protected override void AfterTupleSameInstance( CloneArguments <Tuple <int, int> > args) { base.AfterTupleSameInstance(args); Assert.Equal(1, args.Context.Count); }