public void Dump() { var obj = new MyObject { Property = "value" }; var lines = new List <string>(); obj.Dump(null, s => lines.Add(s)); Assert.AreEqual(2, lines.Count); Assert.IsTrue(lines[0].Contains("MyObject")); Assert.IsTrue(lines[1].Contains("Property")); Assert.IsTrue(lines[1].Contains("value")); obj.ConsoleDump(); }