mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-16 01:41:18 -10:00
2010-07-23 Veerapuram Varadhan <[email protected]>
** Fixes #623451 * DataColumnCollection.cs (MoveColumn): Fix shifting of DataColumn according to the direction of movement.
This commit is contained in:
1 parent
ccc84ffa23
commit
4613d5956f
4 files changed
+44
-1
No files matched your search
@@ -1,3 +1,9 @@
|
||||
2010-07-23 Veerapuram Varadhan <[email protected]>
|
||||
|
||||
** Fixes #623451
|
||||
* DataColumnCollection.cs (MoveColumn): Fix shifting of DataColumn
|
||||
according to the direction of movement.
|
||||
|
||||
2010-06-23 Veerapuram Varadhan <[email protected]>
|
||||
|
||||
** Fixes #581679
|
||||
|
||||
@@ -714,9 +714,16 @@ namespace System.Data {
|
||||
int start = newOrdinal > oldOrdinal ? oldOrdinal : newOrdinal;
|
||||
int end = newOrdinal > oldOrdinal ? newOrdinal : oldOrdinal;
|
||||
int direction = newOrdinal > oldOrdinal ? 1 : (-1);
|
||||
|
||||
// swap ordinals as per direction of column movement
|
||||
if (direction < 0) {
|
||||
start = start + end;
|
||||
end = start - end;
|
||||
start -= end;
|
||||
}
|
||||
|
||||
DataColumn currColumn = this [start];
|
||||
for (int i = start; i < end; i += direction) {
|
||||
for (int i = start; (direction>0 ? i<end : i>end); i += direction) {
|
||||
List [i] = List [i+direction];
|
||||
((DataColumn) List [i]).Ordinal = i;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
2010-07-23 Veerapuram Varadhan <[email protected]>
|
||||
|
||||
* DataColumnTest.cs (B623451_SetOrdinalTest): Added new.
|
||||
|
||||
2010-07-23 Veerapuram Varadhan <[email protected]>
|
||||
|
||||
* DataColumnTest.cs (B565616_NonIConvertibleTypeTest): Added new.
|
||||
|
||||
@@ -887,5 +887,31 @@ namespace MonoTests.System.Data
|
||||
Assert.Fail ("#NonIConvertibleType Test");
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void B623451_SetOrdinalTest ()
|
||||
{
|
||||
try {
|
||||
DataTable t = new DataTable();
|
||||
t.Columns.Add("one");
|
||||
t.Columns.Add("two");
|
||||
t.Columns.Add("three");
|
||||
Assert.AreEqual ("one", t.Columns[0].ColumnName, "#SO1-1");
|
||||
Assert.AreEqual ("two", t.Columns[1].ColumnName, "#SO1-2");
|
||||
Assert.AreEqual ("three", t.Columns[2].ColumnName, "#SO1-3");
|
||||
|
||||
t.Columns["three"].SetOrdinal(0);
|
||||
Assert.AreEqual ("three", t.Columns[0].ColumnName, "S02-1");
|
||||
Assert.AreEqual ("one", t.Columns[1].ColumnName, "S02-2");
|
||||
Assert.AreEqual ("two", t.Columns[2].ColumnName, "S02-3");
|
||||
|
||||
t.Columns["three"].SetOrdinal(1);
|
||||
Assert.AreEqual ("one", t.Columns[0].ColumnName, "S03-1");
|
||||
Assert.AreEqual ("three", t.Columns[1].ColumnName, "S03-2");
|
||||
Assert.AreEqual ("two", t.Columns[2].ColumnName, "S03-3");
|
||||
} catch (ArgumentOutOfRangeException ex) {
|
||||
Assert.Fail ("SetOrdinalTest failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user