public void GetData_Pass_Object_Good() { var getter = new DataGetter(); var data = new DataHolder() { Multipler = 1 }; getter.NewData += (e) => { // This simulates situation where something else changes public property if (e > 2) data.Multipler = 4; Trace.WriteLine(Extensions.TraceMessage(e.ToString())); }; getter.Ready += (s, e) => { stopFlag.Set(); }; getter.GetData_Good(data); stopFlag.WaitOne(); }
public void GetData_Pass_ReferenceType_Bad() { var getter = new DataGetter(); getter.DataHolder = new DataHolder() { Multipler = 1 }; getter.NewData += (e) => { // This simulates situation where something else changes public property if (e > 2) getter.DataHolder.Multipler = 4; Trace.WriteLine(Extensions.TraceMessage(e.ToString())); }; getter.Ready += (s, e) => { stopFlag.Set(); }; getter.GetData_With_ReferenceType(); stopFlag.WaitOne(); }
public void GetData_Use_PublicVariable_Bad() { var getter = new DataGetter(); getter.NewData += (e) => { // This simulates situatin where something else changes public property if (e > 2) getter.Multiplier = 4; Trace.WriteLine(Extensions.TraceMessage(e.ToString())); }; getter.Ready += (s, e) => { stopFlag.Set(); }; getter.GetData(); stopFlag.WaitOne(); }