public void ElementAtOrDefault_InvalidIndex() { TypedTableBase <DataRow> table = new TestTypedTable <DataRow>(); table.Columns.Add(); DataRow zero = table.Rows.Add(0); Assert.Same(default(DataRow), table.ElementAtOrDefault(1)); }
private (TypedTableBase <DataRow> table, DataRow one, DataRow two, DataRow three) InstantiateTable() { TypedTableBase <DataRow> table = new TestTypedTable <DataRow>(); table.Columns.Add(); DataRow two = table.Rows.Add(2); DataRow one = table.Rows.Add(1); DataRow three = table.Rows.Add(3); return(table, one, two, three); }
public void Where_SuccessfullyFindRow() { TypedTableBase <DataRow> table = new TestTypedTable <DataRow>(); table.Columns.Add(); DataRow two = table.Rows.Add("two"); EnumerableRowCollection <DataRow> source = table.Cast <DataRow>(); var filtered = source.Where(row => "two".Equals(row.ItemArray[0])); // Check that only one row matches predicate condition Assert.Equal(1, filtered.Count()); // Check that matching row is the same object as the second data row Assert.Same(two, filtered.First()); }
public void Select_ToListOfInts() { TypedTableBase <DataRow> table = new TestTypedTable <DataRow>(); table.Columns.Add(); table.Rows.Add(10); table.Rows.Add(5); var chosen = table.Select(row => int.Parse((string)row.ItemArray[0])); int total = 0; foreach (int num in chosen) { total += num; } Assert.Equal(15, total); }