public void CloneNotCloneableValueObject() { IDataItem dataItem = new DataItem(); dataItem.Value = mocks.Stub <IFileBased>(); var clone = (DataItem)dataItem.DeepClone(); }
public void CloneShouldNotCausePropertyChangeOnSourceValue() { //set a nameable property changing class in the dataItem var propertyChangingClass = new CloneableClassWithThreeProperties(); var dataItem = new DataItem(propertyChangingClass); propertyChangingClass.PropertyChanged += delegate { Assert.Fail("Clone should not cause a change in the source!"); }; //action clone the dataitem. dataItem.DeepClone(); }
public void Clone() { DataItem di = new DataItem(9, "name", typeof(int), DataItemRole.Output, "tag"); di.Id = 5; DataItem clone = (DataItem)di.DeepClone(); //be sure the id gets reset Assert.AreEqual(0, clone.Id); Assert.AreEqual(di.Value, clone.Value); Assert.AreEqual(di.Name, clone.Name); Assert.AreEqual(di.ValueType, clone.ValueType); Assert.AreEqual(di.Role, clone.Role); Assert.AreEqual(di.Tag, clone.Tag); }
public void CloneLinkedDataItem() { var dataItem = new DataItem(); dataItem.Value = new CloneableClassWithThreeProperties(); //TODO: why do we need to set the valuetype. Why is this not Typeof(value)??? //or (next best) why is this determined at construction time. dataItem.ValueType = typeof(CloneableClassWithThreeProperties); IDataItem linkedDataItem = new DataItem(); linkedDataItem.ValueType = typeof(CloneableClassWithThreeProperties); linkedDataItem.LinkTo(dataItem); Assert.AreEqual(dataItem.ValueType, linkedDataItem.ValueType); //action! clone the linked dataitem var clonedLinkedDataItem = (DataItem)linkedDataItem.DeepClone(); Assert.AreEqual(linkedDataItem.ValueType, clonedLinkedDataItem.ValueType); }
public void Clone() { DataItem di = new DataItem(9,"name",typeof(int),DataItemRole.Output,"tag"); di.Id = 5; DataItem clone = (DataItem) di.DeepClone(); //be sure the id gets reset Assert.AreEqual(0,clone.Id); Assert.AreEqual(di.Value,clone.Value); Assert.AreEqual(di.Name, clone.Name); Assert.AreEqual(di.ValueType, clone.ValueType); Assert.AreEqual(di.Role, clone.Role); Assert.AreEqual(di.Tag, clone.Tag); }
public void CloneLinkedDataItem() { var dataItem = new DataItem(); dataItem.Value = new CloneableClassWithThreeProperties(); //TODO: why do we need to set the valuetype. Why is this not Typeof(value)??? //or (next best) why is this determined at construction time. dataItem.ValueType = typeof (CloneableClassWithThreeProperties); IDataItem linkedDataItem = new DataItem(); linkedDataItem.ValueType = typeof(CloneableClassWithThreeProperties); linkedDataItem.LinkTo(dataItem); Assert.AreEqual(dataItem.ValueType,linkedDataItem.ValueType); //action! clone the linked dataitem var clonedLinkedDataItem = (DataItem)linkedDataItem.DeepClone(); Assert.AreEqual(linkedDataItem.ValueType,clonedLinkedDataItem.ValueType ); }
public void CloneNotCloneableValueObject() { IDataItem dataItem = new DataItem(); dataItem.Value = mocks.Stub<IFileBased>(); var clone = (DataItem)dataItem.DeepClone(); }