public void should_get_copy_of_the_argument_when_passing_by_value_for_ref_type() { var refTypeObject = new RefTypeClass(1); RefTypeClass modifiedRefTypeObject = FunctionPassingRefTypeClassAsArgument(refTypeObject); // change the variable value to correct one. RefTypeClass expectedResult = modifiedRefTypeObject; Assert.Same(expectedResult, refTypeObject); }
public void should_initialize_to_default_value() { var defaultValueDemo = new DefaultValueDemoClass(); // change the variable values of the following 2 lines to correct values var expectedReferenceTypeValue = new RefTypeClass(default(int)); const int expectedValueTypeValue = 1; Assert.Equal(expectedReferenceTypeValue, defaultValueDemo.referenceTypeValue); Assert.Equal(expectedValueTypeValue, defaultValueDemo.valueTypeValue); }
private RefTypeClass FunctionPassingRefRefTypeClassAsArgument( ref RefTypeClass refTypeObject) { refTypeObject = new RefTypeClass(2); return refTypeObject; }
private static RefTypeClass FunctionPassingOutRefTypeClassAsArgument( out RefTypeClass refTypeObject) { refTypeObject = new RefTypeClass(1); return refTypeObject; }
public void should_ref_to_same_location_when_passing_by_ref_for_ref_type() { var refTypeObject = new RefTypeClass(1); RefTypeClass refToOriginalObject = refTypeObject; RefTypeClass modifiedRefTypeObject = FunctionPassingRefRefTypeClassAsArgument( ref refTypeObject); // change the variable value to correct one object expectedResult = refToOriginalObject; Assert.Same(expectedResult, refTypeObject); }
public void should_print_object_type_if_no_override_is_available_for_to_string_method() { var objectWithoutToStringOverride = new RefTypeClass(2); // change the variable value to fix the test. const string expectedToStringResult = ""; string toStringResult = objectWithoutToStringOverride.ToString(); Assert.Equal(expectedToStringResult, toStringResult); }