public void Add() { var list1 = new DList <DObject>(); list1.Add(new { value = "1" }); list1.Single().GetString("value").ShouldBe("1"); Should.Throw <InvalidCastException>(() => list1.Add(2)); var list2 = new DList <int>(); list2.Add(1); list2.Single().ShouldBe(1); Should.Throw <InvalidCastException>(() => list2.Add(new { value = "2" })); }