예제 #1
0
		public void TestEquals_SameTableDiffViewProp()
		{

			DataTable table = new DataTable("table");
			table.Columns.Add("col1", typeof(int));
			table.Columns.Add("col2", typeof(int));
			for (int i = 0; i < 5; ++i)
				table.Rows.Add(new object[] { i, 100 + i });

			DataView view1 = new DataView(table);
			DataView view2 = new DataView(table);

			object obj2 = (object)view2;
			Assert.IsFalse(view1.Equals(obj2), "#1");

			Assert.IsTrue(view1.Equals(view1), "#2");
			Assert.IsTrue(view2.Equals(view1), "#3");

			view1.Sort = "col1 ASC";
			Assert.IsFalse(view1.Equals(view2), "#4");
			view2.Sort = "col1 ASC";
			Assert.IsTrue(view1.Equals(view2), "#5");

			view1.RowFilter = "col1 > 100";
			Assert.IsFalse(view1.Equals(view2), "#6");
			view1.RowFilter = "";
			Assert.IsTrue(view1.Equals(view2), "#7");

			view1.RowStateFilter = DataViewRowState.Added;
			Assert.IsFalse(view1.Equals(view2), "#8");
			view1.RowStateFilter = DataViewRowState.CurrentRows;
			Assert.IsTrue(view1.Equals(view2), "#9");

			view1.AllowDelete = !view2.AllowDelete;
			Assert.IsFalse(view1.Equals(view2), "#10");
			view1.AllowDelete = view2.AllowDelete;
			Assert.IsTrue(view1.Equals(view2), "#11");

			view1.AllowEdit = !view2.AllowEdit;
			Assert.IsFalse(view1.Equals(view2), "#12");
			view1.AllowEdit = view2.AllowEdit;
			Assert.IsTrue(view1.Equals(view2), "#13");

			view1.AllowNew = !view2.AllowNew;
			Assert.IsFalse(view1.Equals(view2), "#14");
			view1.AllowNew = view2.AllowNew;
			Assert.IsTrue(view1.Equals(view2), "#15");

			//ApplyDefaultSort doesnet affect the comparision
			view1.ApplyDefaultSort = !view2.ApplyDefaultSort;
			Assert.IsTrue(view1.Equals(view2), "#16");

			DataTable table2 = table.Copy();
			view1.Table = table2;
			Assert.IsFalse(view1.Equals(view2), "#17");

			view1.Table = table;
			//well.. sort is set to null when Table is assigned..
			view1.Sort = view2.Sort;          
			Assert.IsTrue(view1.Equals(view2), "#18"); 
		}