Beispiel #1
0
        public void UnlimitedNestingDepthWorksAsExpected()
        {
            var mapper = new MemberMapper();

            var nested = new NestedA
            {
                Bar    = "A",
                Nested = new NestedB
                {
                    Bar    = "B",
                    Nested = new[]
                    {
                        new NestedC
                        {
                            Bar    = "C",
                            Nested = new NestedD
                            {
                                Bar = "D"
                            }
                        }
                    }
                }
            };

            mapper.Options.Cloning.MaxCloneDepth = null;
            var clone = mapper.DeepClone(nested);

            Assert.IsNotNull(clone.Nested);
            Assert.IsNotNull(clone.Nested.Nested);
            Assert.IsNotNull(clone.Nested.Nested.Single().Nested);
        }
Beispiel #2
0
        public void DefaultNestingDepthWorksAsExpected()
        {
            var mapper = new MemberMapper();

            var nested = new NestedA
            {
                Bar    = "A",
                Nested = new NestedB
                {
                    Bar    = "B",
                    Nested = new[]
                    {
                        new NestedC
                        {
                            Bar    = "C",
                            Nested = new NestedD
                            {
                                Bar = "D"
                            }
                        }
                    }
                }
            };

            var clone = mapper.DeepClone(nested);

            Assert.IsNotNull(clone.Nested);
            Assert.IsNotNull(clone.Nested.Nested);
            Assert.IsNull(clone.Nested.Nested.Single().Nested);
        }
Beispiel #3
0
        public void ChangedNestingDepthWorksAsExpected()
        {
            var mapper = new MemberMapper();

              var nested = new NestedA
              {
            Bar = "A",
            Nested = new NestedB
            {
              Bar = "B",
              Nested = new[]
              {
            new NestedC
            {
              Bar = "C",
              Nested = new NestedD
              {
                Bar = "D"
              }
            }
              }
            }
              };
              mapper.Options.Cloning.MaxCloneDepth = 1;
              var clone = mapper.DeepClone(nested);

              Assert.IsNotNull(clone.Nested);
              Assert.IsNull(clone.Nested.Nested);
        }
    public override bool Equals(object obj)
    {
        NestedA other = obj as NestedA;

        if (other == null)
        {
            return(false);
        }
        return(NestedBList.SequenceEqual(other.NestedBList) && NestedCList.SequenceEqual(other.NestedCList));
    }
Beispiel #5
0
        public void DefaultNestingDepthWorksAsExpected()
        {
            var mapper = new MemberMapper();

              var nested = new NestedA
              {
            Bar = "A",
            Nested = new NestedB
            {
              Bar = "B",
              Nested = new[]
              {
            new NestedC
            {
              Bar = "C",
              Nested = new NestedD
              {
                Bar = "D"
              }
            }
              }
            }
              };

              var clone = mapper.DeepClone(nested);

              Assert.IsNotNull(clone.Nested);
              Assert.IsNotNull(clone.Nested.Nested);
              Assert.IsNull(clone.Nested.Nested.Single().Nested);
        }