private void MethodThatChangesParamNotByRef(MyTestClass myTestClass) { myTestClass = new MyTestClass() { AProperty = "Esto no se debería cambiar" }; }
public void When_Modify_Reference_WithoutRef_Then_OuterMethodClassRemains() { var myClass = new MyTestClass() { AProperty = "Hello Motto" }; MethodThatChangesParamNotByRef(myClass); Assert.AreEqual("Hello Motto", myClass.AProperty); }
public void When_Modify_Reference_WithtRef_Then_OuterMethodClassChanges() { var myClass = new MyTestClass() { AProperty = "Hello Motto" }; MethodThatChangesParamByRef(ref myClass); Assert.AreEqual("Esto SI se debería cambiar", myClass.AProperty); }