public void RowCount2() { var tests = new List <Test> { new Test { Id = 1 , Name = "A" } , new Test { Id = 2 , Name = "B" } }; var target = new DataTableWithSerialGenerator <Test>(); target.AddRange(tests); var actual = target.Result; var expected = new DataTable(); expected.Columns.Add("Id"); expected.Columns.Add("Name"); expected.Columns.Add("Serial"); var row = expected.NewRow(); row["Id"] = 1; row["Name"] = "A"; row["Serial"] = 1; expected.Rows.Add(row); row = expected.NewRow(); row["Id"] = 2; row["Name"] = "B"; row["Serial"] = 2; expected.Rows.Add(row); Assert.IsTrue(IsTableSame(expected, actual)); }
public void RowCount1WithNullableInt() { var tests = new List <Test2> { new Test2 { Id = null , Name = "A" } }; var target = new DataTableWithSerialGenerator <Test2>(); target.AddRange(tests); var actual = target.Result; var expected = new DataTable(); var column = new DataColumn(); column.ColumnName = "Id"; column.AllowDBNull = true; column.DataType = Nullable.GetUnderlyingType(typeof(Int32?)); expected.Columns.Add(column); expected.Columns.Add("Name"); expected.Columns.Add("Serial"); var row = expected.NewRow(); row["Id"] = DBNull.Value; row["Name"] = "A"; row["Serial"] = 1; expected.Rows.Add(row); Assert.IsTrue(IsTableSame(expected, actual)); }