Esempio n. 1
0
        public void WithListOfIntsToEmpty()
        {
            var x = new WithListProperty <int> {
                Items = { 1, 2, 3 }
            };
            var y      = new WithListProperty <int>();
            var result = this.EqualMethod(x, y, ReferenceHandling.Structural);

            Assert.AreEqual(false, result);
        }
Esempio n. 2
0
        public void WithListOfIntsToEmpty()
        {
            var source = new WithListProperty <int>();

            source.Items.AddRange(new[] { 1, 2, 3 });
            var target = new WithListProperty <int>();

            this.CopyMethod(source, target, ReferenceHandling.Structural);
            CollectionAssert.AreEqual(source.Items, target.Items);
        }
Esempio n. 3
0
        public void WithListOfComplexPropertyToEmptyStructural()
        {
            var x = new WithListProperty <ComplexType> {
                Items = { new ComplexType("a", 1) }
            };
            var y = new WithListProperty <ComplexType> {
                Items = { new ComplexType("a", 1) }
            };
            var result = this.EqualMethod(x, y, ReferenceHandling.Structural);

            Assert.AreEqual(true, result);
        }
Esempio n. 4
0
        public void WithListOfComplexPropertyToEmptyReference()
        {
            var source = new WithListProperty <ComplexType>();

            source.Items.Add(new ComplexType("a", 1));
            var target = new WithListProperty <ComplexType>();

            this.CopyMethod(source, target, ReferenceHandling.References);
            var expected = new[] { new ComplexType("a", 1) };

            CollectionAssert.AreEqual(expected, source.Items, ComplexType.Comparer);
            CollectionAssert.AreEqual(expected, target.Items, ComplexType.Comparer);
            Assert.AreSame(source.Items[0], target.Items[0]);
        }
Esempio n. 5
0
        public void WithListOfIntsNullToNull(ReferenceHandling referenceHandling)
        {
            var x = new WithListProperty <int> {
                Items = null
            };
            var y = new WithListProperty <int> {
                Items = null
            };

            var result = this.DiffMethod(x, y, referenceHandling);

            Assert.AreEqual(true, result.IsEmpty);
            Assert.AreEqual("Empty", result.ToString());
        }
Esempio n. 6
0
        public void WithListOfIntsNullToNull()
        {
            var x = new WithListProperty <int> {
                Items = null
            };
            var y = new WithListProperty <int> {
                Items = null
            };
            var result = this.EqualMethod(x, y, ReferenceHandling.Structural);

            Assert.AreEqual(true, result);

            result = this.EqualMethod(x, y, ReferenceHandling.References);
            Assert.AreEqual(true, result);
        }
Esempio n. 7
0
        public void WithListOfIntsPropertyToLonger()
        {
            var x = new WithListProperty <int> {
                Items = { 1, 2, 3 }
            };
            var y = new WithListProperty <int> {
                Items = { 1, 2, 3, 4 }
            };
            var result   = this.DiffMethod(x, y, ReferenceHandling.Structural);
            var expected = this is FieldValues.Classes
                               ? "WithListProperty<int> <Items>k__BackingField [3] x: missing item y: 4"
                               : "WithListProperty<int> Items [3] x: missing item y: 4";

            Assert.AreEqual(expected, result.ToString(string.Empty, " "));
        }
Esempio n. 8
0
        public void WithListOfIntsToNull()
        {
            var x = new WithListProperty <int> {
                Items = { 1, 2, 3 }
            };
            var y = new WithListProperty <int> {
                Items = null
            };
            var result   = this.DiffMethod(x, y, ReferenceHandling.Structural);
            var expected = this is FieldValues.Classes
                               ? "WithListProperty<int> <Items>k__BackingField x: System.Collections.Generic.List`1[System.Int32] y: null"
                               : "WithListProperty<int> Items x: System.Collections.Generic.List`1[System.Int32] y: null";

            Assert.AreEqual(expected, result.ToString(string.Empty, " "));
        }
Esempio n. 9
0
        public void WithListOfIntsToEmpty()
        {
            var x = new WithListProperty <int> {
                Items = { 1, 2, 3 }
            };
            var y        = new WithListProperty <int>();
            var expected = this is FieldValues.Classes
                   ? "WithListProperty<int> <Items>k__BackingField [0] x: 1 y: missing item [1] x: 2 y: missing item [2] x: 3 y: missing item"
                   : "WithListProperty<int> Items [0] x: 1 y: missing item [1] x: 2 y: missing item [2] x: 3 y: missing item";

            var result = this.DiffMethod(x, y, ReferenceHandling.Structural);

            Assert.AreEqual(false, result.IsEmpty);
            Assert.AreEqual(expected, result.ToString(string.Empty, " "));
        }
Esempio n. 10
0
        public void WithListOfComplexPropertyToLonger()
        {
            var source = new WithListProperty <ComplexType> {
                Items = { new ComplexType("a", 1) }
            };
            var target = new WithListProperty <ComplexType>
            {
                Items =
                {
                    new ComplexType("a", 1),
                    new ComplexType("a", 1)
                }
            };
            var result = this.EqualMethod(source, target, ReferenceHandling.Structural);

            Assert.AreEqual(false, result);
        }
Esempio n. 11
0
        public void WithListOfComplexPropertyToLonger()
        {
            var source = new WithListProperty <ComplexType>();

            source.Items.Add(new ComplexType("a", 1));
            var target = new WithListProperty <ComplexType>();

            target.Items.AddRange(new[] { new ComplexType("b", 2), new ComplexType("c", 3) });
            var item = target.Items[0];

            this.CopyMethod(source, target, ReferenceHandling.Structural);
            var expected = new[] { new ComplexType("a", 1) };

            CollectionAssert.AreEqual(expected, source.Items, ComplexType.Comparer);
            CollectionAssert.AreEqual(expected, target.Items, ComplexType.Comparer);
            Assert.AreSame(item, target.Items[0]);
        }
Esempio n. 12
0
        public void WithListOfComplexPropertyToLonger()
        {
            var source = new WithListProperty <ComplexType> {
                Items = { new ComplexType("a", 1) }
            };
            var target = new WithListProperty <ComplexType>
            {
                Items =
                {
                    new ComplexType("a", 1),
                    new ComplexType("a", 1)
                }
            };
            var result   = this.DiffMethod(source, target, ReferenceHandling.Structural);
            var expected = this is FieldValues.Classes
                               ? "WithListProperty<ComplexType> <Items>k__BackingField [1] x: missing item y: Gu.State.Tests.DiffTests.DiffTypes+ComplexType"
                               : "WithListProperty<ComplexType> Items [1] x: missing item y: Gu.State.Tests.DiffTests.DiffTypes+ComplexType";

            Assert.AreEqual(expected, result.ToString(string.Empty, " "));
        }
Esempio n. 13
0
        public void WithListOfIntsEmptyToEmpty()
        {
            var x = new WithListProperty <int> {
                Items = new List <int>()
            };
            var y = new WithListProperty <int> {
                Items = new List <int>()
            };

            var result = this.DiffMethod(x, y, ReferenceHandling.Structural);

            Assert.AreEqual(true, result.IsEmpty);
            Assert.AreEqual("Empty", result.ToString());

            result = this.DiffMethod(x, y, ReferenceHandling.References);
            Assert.AreEqual(false, result.IsEmpty);
            var expected = this is FieldValues.Classes
                               ? "WithListProperty<int> <Items>k__BackingField x: System.Collections.Generic.List`1[System.Int32] y: System.Collections.Generic.List`1[System.Int32]"
                               : "WithListProperty<int> Items x: System.Collections.Generic.List`1[System.Int32] y: System.Collections.Generic.List`1[System.Int32]";

            Assert.AreEqual(expected, result.ToString(string.Empty, " "));
        }