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); }
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); }
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); }
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]); }
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()); }
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); }
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, " ")); }
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, " ")); }
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, " ")); }
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); }
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]); }
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, " ")); }
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, " ")); }