Streamlined the cloning API: whether a property-based clone is performed is no longer indicated through a parameter, but by calling the appropriate method

git-svn-id: file:///srv/devel/repo-conversion/nusu@245 d2e56fa2-650e-0410-a79f-9358c0239efd
This commit is contained in:
Markus Ewald 2012-02-08 17:13:08 +00:00
parent 0f2bb60ea5
commit 15300676ba
7 changed files with 277 additions and 177 deletions

View file

@ -40,7 +40,7 @@ namespace Nuclex.Support.Cloning {
[Test]
public void PrimitiveTypesCanBeCloned() {
int original = 12345;
int clone = this.cloneFactory.DeepClone(original, false);
int clone = this.cloneFactory.DeepFieldClone(original);
Assert.AreEqual(original, clone);
}
@ -48,7 +48,7 @@ namespace Nuclex.Support.Cloning {
[Test]
public void ReferenceTypesCanBeCloned() {
var original = new TestReferenceType() { TestField = 123, TestProperty = 456 };
TestReferenceType clone = this.cloneFactory.DeepClone(original, false);
TestReferenceType clone = this.cloneFactory.DeepFieldClone(original);
Assert.AreNotSame(original, clone);
Assert.AreEqual(original.TestField, clone.TestField);
@ -59,7 +59,7 @@ namespace Nuclex.Support.Cloning {
[Test]
public void PrimitiveArraysCanBeCloned() {
var original = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
int[] clone = this.cloneFactory.DeepClone(original, false);
int[] clone = this.cloneFactory.DeepFieldClone(original);
Assert.AreNotSame(original, clone);
CollectionAssert.AreEqual(original, clone);
@ -71,7 +71,7 @@ namespace Nuclex.Support.Cloning {
var original = new TestReferenceType[] {
new TestReferenceType() { TestField = 123, TestProperty = 456 }
};
TestReferenceType[] clone = this.cloneFactory.ShallowClone(original, false);
TestReferenceType[] clone = this.cloneFactory.ShallowFieldClone(original);
Assert.AreSame(original[0], clone[0]);
}
@ -84,7 +84,7 @@ namespace Nuclex.Support.Cloning {
new TestReferenceType() { TestField = 123, TestProperty = 456 }
}
};
TestReferenceType[,] clone = this.cloneFactory.DeepClone(original, false);
TestReferenceType[,] clone = this.cloneFactory.DeepFieldClone(original);
Assert.AreNotSame(original[0, 0], clone[0, 0]);
Assert.AreEqual(original[0, 0].TestField, clone[0, 0].TestField);
@ -95,7 +95,7 @@ namespace Nuclex.Support.Cloning {
[Test]
public void GenericListsCanBeCloned() {
var original = new List<int>(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 });
List<int> clone = this.cloneFactory.DeepClone(original, false);
List<int> clone = this.cloneFactory.DeepFieldClone(original);
CollectionAssert.AreEqual(original, clone);
}
@ -105,7 +105,7 @@ namespace Nuclex.Support.Cloning {
public void GenericDictionariesCanBeCloned() {
var original = new Dictionary<int, string>();
original.Add(1, "one");
Dictionary<int, string> clone = this.cloneFactory.DeepClone(original, false);
Dictionary<int, string> clone = this.cloneFactory.DeepFieldClone(original);
Assert.AreEqual("one", clone[1]);
}
@ -116,7 +116,7 @@ namespace Nuclex.Support.Cloning {
[Test]
public void ShallowFieldBasedClonesOfValueTypesCanBeMade() {
HierarchicalValueType original = CreateValueType();
HierarchicalValueType clone = this.cloneFactory.ShallowClone(original, false);
HierarchicalValueType clone = this.cloneFactory.ShallowFieldClone(original);
VerifyClone(ref original, ref clone, isDeepClone: false, isPropertyBasedClone: false);
}
@ -126,7 +126,7 @@ namespace Nuclex.Support.Cloning {
[Test]
public void ShallowFieldBasedClonesOfReferenceTypesCanBeMade() {
HierarchicalReferenceType original = CreateReferenceType();
HierarchicalReferenceType clone = this.cloneFactory.ShallowClone(original, false);
HierarchicalReferenceType clone = this.cloneFactory.ShallowFieldClone(original);
VerifyClone(original, clone, isDeepClone: false, isPropertyBasedClone: false);
}
@ -136,7 +136,7 @@ namespace Nuclex.Support.Cloning {
[Test]
public void DeepFieldBasedClonesOfValueTypesCanBeMade() {
HierarchicalValueType original = CreateValueType();
HierarchicalValueType clone = this.cloneFactory.DeepClone(original, false);
HierarchicalValueType clone = this.cloneFactory.DeepFieldClone(original);
VerifyClone(ref original, ref clone, isDeepClone: true, isPropertyBasedClone: false);
}
@ -146,7 +146,7 @@ namespace Nuclex.Support.Cloning {
[Test]
public void DeepFieldBasedClonesOfReferenceTypesCanBeMade() {
HierarchicalReferenceType original = CreateReferenceType();
HierarchicalReferenceType clone = this.cloneFactory.DeepClone(original, false);
HierarchicalReferenceType clone = this.cloneFactory.DeepFieldClone(original);
VerifyClone(original, clone, isDeepClone: true, isPropertyBasedClone: false);
}
@ -178,7 +178,7 @@ namespace Nuclex.Support.Cloning {
[Test]
public void DeepPropertyBasedClonesOfValueTypesCanBeMade() {
HierarchicalValueType original = CreateValueType();
HierarchicalValueType clone = this.cloneFactory.DeepClone(original, true);
HierarchicalValueType clone = this.cloneFactory.DeepPropertyClone(original);
VerifyClone(ref original, ref clone, isDeepClone: true, isPropertyBasedClone: true);
}
@ -188,7 +188,7 @@ namespace Nuclex.Support.Cloning {
[Test]
public void DeepPropertyBasedClonesOfReferenceTypesCanBeMade() {
HierarchicalReferenceType original = CreateReferenceType();
HierarchicalReferenceType clone = this.cloneFactory.DeepClone(original, true);
HierarchicalReferenceType clone = this.cloneFactory.DeepPropertyClone(original);
VerifyClone(original, clone, isDeepClone: true, isPropertyBasedClone: true);
}