public static TestClass2 Create() { return(new() { Class1 = TestClass1.Create(), Class1Array = new TestClass1[] { TestClass1.Create(), TestClass1.Create(), TestClass1.Create() }, Class1Dict = new() { ["foo"] = TestClass1.Create(),
public void AClassIsTheMostCommonReferenceType() { var obj = TestClass1.Create(); // a class is a reference type, which are stored on the heap // a reference (variable here is obj) is a stored on the stack // the reference is only the location of the object on the heap, not the entire object data Assert.That(obj.GetType().IsSubclassOf(typeof(ValueType)), Is.Not.True); // field initialization is optional, will use default values // default values are often a bitwise '0' of value Assert.That(obj.Number, Is.EqualTo(0)); // for an int that would be '0x00000000' (an int is 32 bits/4 bytes) // CANNOT do this... a readonly field can only be written to in a constructor //obj.ReadonlyField = 67; Assert.That(obj.ReadonlyField, Is.EqualTo(67)); }