using System.Collections.Generic;
public static void Main()
var t = new Test { Foo = "Hello world" };
var tracked = new List<(Test Object, Dictionary<string, object> Properties)>();
var currentProperties = GetProps(t);
tracked.Add((t, currentProperties));
var capturedFoo1 = tracked[0].Properties["Foo"].ToString();
var capturedBar1 = (List<string>) tracked[0].Properties["Bar"];
Console.WriteLine($"Expected '{t.Foo}' Actual: '{capturedFoo1}'");
Console.WriteLine($"Expected 0 Actual: {(capturedBar1.Count())}");
Console.WriteLine(Environment.NewLine);
var capturedFoo2 = tracked[0].Properties["Foo"].ToString();
var capturedBar2 = (List<string>) tracked[0].Properties["Bar"];
Console.WriteLine($"Expected 'Hello world' Actual: '{capturedFoo2}'");
Console.WriteLine($"Expected 0 Actual: {(capturedBar2.Count())}");
public static Dictionary<string, object> GetProps(Test t)
=> t.GetType().GetProperties().ToDictionary(p => p.Name, p => p.GetValue(t));
public string Foo { get; set; }
public List<string> Bar {get;set;} = new();