public void TestCreateAdapter() { DataTableAdapterFactory factory = new DataTableAdapterFactory(); PropertyColumn[] columns = new PropertyColumn[] { new PropertyColumn("Class1.Field", "Field"), new PropertyColumn("Class1.Property", "Property"), new PropertyColumn("Time", "Time") }; IDataTableAdapter <TestClass2> adapter = factory.New <TestClass2>(columns); List <TestClass2> list = new List <TestClass2>(); for (int i = 0; i < 10000; i++) { list.Add(new TestClass2(new TestClass1(4, "4"))); list.Add(new TestClass2(new TestClass1(40, "40"))); list.Add(new TestClass2(new TestClass1(12, "12"))); list.Add(new TestClass2()); } DataTable dt = adapter.Get(list); Assert.IsNotNull(dt); Assert.AreEqual(list.Count, dt.Rows.Count); Assert.AreEqual(4, dt.Columns.Count); Assert.AreEqual(list[0].Class1.Property, dt.Rows[0]["Property"]); Assert.AreEqual(list[0].Class1.Field, dt.Rows[0]["Field"]); Assert.AreEqual(list[0].Time, dt.Rows[0]["Time"]); Assert.AreSame(list[0], dt.Rows[0]["DataItem"]); IDataTableAdapter <TestClass2> adapter2 = factory.New <TestClass2>(columns); Assert.AreSame(adapter, adapter2); PropertyColumn[] columns2 = new PropertyColumn[] { new PropertyColumn("Class1.Field", "Field") }; IDataTableAdapter <TestClass2> adapter3 = factory.New <TestClass2>(columns2); Assert.AreNotSame(adapter, adapter3); }
public void TestCreateAdapter() { DataTableAdapterFactory factory = new DataTableAdapterFactory(); PropertyColumn[] columns = new PropertyColumn[] { new PropertyColumn("Class1.Field", "Field"), new PropertyColumn("Class1.Property", "Property"), new PropertyColumn("Time", "Time") }; IDataTableAdapter<TestClass2> adapter = factory.New<TestClass2>(columns); List<TestClass2> list = new List<TestClass2>(); for (int i = 0; i < 10000; i++) { list.Add(new TestClass2(new TestClass1(4, "4"))); list.Add(new TestClass2(new TestClass1(40, "40"))); list.Add(new TestClass2(new TestClass1(12, "12"))); list.Add(new TestClass2()); } DataTable dt = adapter.Get(list); Assert.IsNotNull(dt); Assert.AreEqual(list.Count, dt.Rows.Count); Assert.AreEqual(4, dt.Columns.Count); Assert.AreEqual(list[0].Class1.Property, dt.Rows[0]["Property"]); Assert.AreEqual(list[0].Class1.Field, dt.Rows[0]["Field"]); Assert.AreEqual(list[0].Time, dt.Rows[0]["Time"]); Assert.AreSame(list[0], dt.Rows[0]["DataItem"]); IDataTableAdapter<TestClass2> adapter2 = factory.New<TestClass2>(columns); Assert.AreSame(adapter, adapter2); PropertyColumn[] columns2 = new PropertyColumn[] { new PropertyColumn("Class1.Field", "Field") }; IDataTableAdapter<TestClass2> adapter3 = factory.New<TestClass2>(columns2); Assert.AreNotSame(adapter, adapter3); }