public void Test1() { var m = ModerateClass.CreateForTests(1); var mCopy = (ModerateClass)CopyFunctionSelection._copyMethod(m); // test that the copy is a different instance but with equal content Assert_AreEqualButNotSame(m, mCopy); // test of copy if we insert it as interface var mAsCopiedAsInterface = (ModerateClass)CopyFunctionSelection._copyMethod((ISimpleClass)m); Assert_AreEqualButNotSame(m, mAsCopiedAsInterface); }
public void Test1() { var s = SimpleClass.CreateForTests(1); var sCopy = (SimpleClass)CopyFunctionSelection._copyMethod(s); // test that the copy is a different instance but with equal content Assert_AreEqualButNotSame(s, sCopy); // test of method "CreateForTests" that it creates different content var s2 = SimpleClass.CreateForTests(2); Assert.AreNotEqual(s._fieldPublic, s2._fieldPublic); Assert.AreNotEqual(s.PropertyPublic, s2.PropertyPublic); Assert.AreNotEqual(s._readOnlyField, s2._readOnlyField); Assert.AreNotEqual(s.GetPrivateField(), s2.GetPrivateField()); Assert.AreNotEqual(s.GetPrivateProperty(), s2.GetPrivateProperty()); }
public void Test1() { var c = ComplexClass.CreateForTests(); var cCopy = (ComplexClass)CopyFunctionSelection._copyMethod(c); // test that the copy is a different instance but with equal content Assert_AreEqualButNotSame(c, cCopy); // test that the same subobjects should remain the same in a copy (we put same objects to different dictionaries) Assert.AreSame(cCopy._sampleDictionary[typeof(ComplexClass).ToString()], cCopy.ISampleDictionary[typeof(ComplexClass).ToString()]); Assert.AreSame(cCopy._sampleDictionary[typeof(ModerateClass).ToString()], cCopy.ISampleDictionary[typeof(ModerateClass).ToString()]); Assert.AreNotSame(cCopy._sampleDictionary[typeof(SimpleClass).ToString()], cCopy.ISampleDictionary[typeof(SimpleClass).ToString()]); Assert.AreSame(cCopy._iSimpleMultiDimArray[0, 0, 0], cCopy._simpleMultiDimArray[1][1][1]); }