public void CovariantTest() { const int numberInRange = 100; List <int> data = Enumerable.Range(0, numberInRange).ToList(); string expectedResult = string.Join(",", data); IRunOnceEnumerable <ChildClass> e = data.Select(s => new ChildClass(s)).OnlyRunOnce(); // This is really a compiler time test. // This method will only be callable if IRunOnceEnumerable is covariant. // It will produce a compiler error otherwise. string actualResult = CovariantAction(e); Assert.AreEqual(expectedResult, actualResult); }
private string CovariantAction(IRunOnceEnumerable <ParentClass> data) { return(string.Join(",", data.Select(d => d.StringData))); }