the test class is like this :
public static class Test
{
public static testclass Create()
{
RefClass2 oRef = new RefClass2()
{
Class2ID = ",id2,",
Class2Name = "name2"
};
RefClass2 oRef2 = new RefClass2()
{
Class2ID = "id3",
Class2Name = "name3"
};
RefClass1 oTeacher = new RefClass1()
{
Class1ID = "id1",
Class1Name = "name1",
Class1ObjType = EnumObj1.A,
RefClass = oRef
};
RefClass1 oTeacher2 = new RefClass1()
{
Class1ID = "\"id4\"",
Class1Name = "name4",
Class1ObjType = EnumObj1.B,
RefClass = oRef2
};
testclass oRet = new testclass()
{
Name = "xiao ming",
Age = 16,
ShirtColor = ConsoleColor.Blue,
Mode = StartMode.Manual,
PreviewExecuteionTime = null,
NextExecuteionTime = DateTime.Now,
Teachers = new RefClass1[2] { oTeacher, oTeacher2 }
};
return oRet;
}
}
public class testclass
{
public string Name { get; set; }
public int Age { get; set; }
public string School { get; private set; }
public ConsoleColor ShirtColor { get; set; }
public StartMode Mode{get;set;}
public string ModeText
{
get
{
if (Mode == StartMode.Auto)
{
return "0";
}
return "1";
}
}
public DateTimeOffset? PreviewExecuteionTime { get; set; }
public DateTimeOffset? NextExecuteionTime { get; set; }
public RefClass1[] Teachers { get; set; }
}
public enum StartMode
{
Auto = 0,
Manual = 1
}
public class RefClass1
{
public string Class1ID { get; set; }
public string Class1Name { get; set; }
public EnumObj1 Class1ObjType { get; set; }
public RefClass2 RefClass { get; set; }
}
public class RefClass2
{
public string Class2ID { get; set; }
public string Class2Name { get; set; }
}
public enum EnumObj1
{
A = 0,
B = 1
}
invoke the Test.Create() static method can create a testing object.