本文整理汇总了C#中Course.DeepClone方法的典型用法代码示例。如果您正苦于以下问题:C# Course.DeepClone方法的具体用法?C# Course.DeepClone怎么用?C# Course.DeepClone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Course
的用法示例。
在下文中一共展示了Course.DeepClone方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestDeepClone_BasicTypes
public void TestDeepClone_BasicTypes()
{
/*
* Test primitive types + array type.
*/
var pupil1 = new Pupil(1, "A", Gender.Male, new DateTime(2015, 01, 01));
var course1 = new Course {Id = 1, Name = "C#"};
course1.Pupils = new Pupil[] {pupil1};
pupil1.Course = course1;
var clonePupil1= pupil1.DeepClone();
Assert.NotEqual(clonePupil1, pupil1);
Assert.NotSame(clonePupil1, pupil1);
Assert.True(Pupil.ValueEqual(pupil1, clonePupil1));
var cloneCourse1 = course1.DeepClone();
Assert.NotEqual(cloneCourse1, course1);
Assert.NotSame(cloneCourse1, course1);
Assert.NotEqual(cloneCourse1.Pupils, course1.Pupils);
Assert.NotSame(cloneCourse1.Pupils, course1.Pupils);
Assert.NotEqual(cloneCourse1.Pupils[0], course1.Pupils[0]);
Assert.NotSame(cloneCourse1.Pupils[0], course1.Pupils[0]);
Assert.True(Pupil.ValueEqual(cloneCourse1.Pupils[0], course1.Pupils[0]));
Assert.Equal(course1.Pupils[0], pupil1);
Assert.Same(course1.Pupils[0], pupil1);
Assert.True(Pupil.ValueEqual(course1.Pupils[0], pupil1));
Assert.NotEqual(cloneCourse1.Pupils[0], pupil1);
Assert.NotSame(cloneCourse1.Pupils[0], pupil1);
Assert.True(Pupil.ValueEqual(cloneCourse1.Pupils[0], pupil1));
Assert.Same(course1.Pupils[0].Course, course1);
Assert.NotSame(course1.Pupils[0].Course, cloneCourse1);
Assert.Same(cloneCourse1.Pupils[0].Course, cloneCourse1);
}