public void TestDeepCopy() { _abilityCollection = new AbilityCollection(); _abilityCollection.Add(_ability1); _abilityCollection.Add(_ability2); _abilityCollection.Add(_ability3); // Make sure shallow copy is the same AbilityCollection shallowCopy = _abilityCollection; Assert.AreSame(_abilityCollection, shallowCopy); // Make sure deep copy is different AbilityCollection deepCopy = _abilityCollection.DeepCopy(); Assert.AreNotSame(_abilityCollection, deepCopy); }
/// <summary> /// Returns a deep copied instance. /// </summary> /// <returns>The copy.</returns> public UnitData DeepCopy() { return(new UnitData(ResRef, FirstName, LastName, Class, Portrait, MovementSound, Sprite, Type, AttributeCollection.DeepCopy(), InventorySlots.DeepCopy(), AbilityCollection.DeepCopy())); }