Skip to content

Commit b9d8d84

Browse files
authored
Make test System.Data.Tests.AppDomainsAndFormatInfo.Bug55978 more robust (#63028)
Add explicit 1 minute difference to all datetimes in rows.
1 parent 4e2102b commit b9d8d84

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/libraries/System.Data.Common/tests/System/Data/DataTableTest.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3566,34 +3566,38 @@ public void Remote()
35663566
}
35673567

35683568
[Fact]
3569-
[ActiveIssue("https://github.com/dotnet/runtime/issues/62965", TestPlatforms.Browser)] // fails on NodeJS on windows
35703569
public void Bug55978()
35713570
{
35723571
DataTable dt = new DataTable();
35733572
dt.Columns.Add("StartDate", typeof(DateTime));
35743573

35753574
DataRow dr;
3576-
DateTime date = DateTime.Now;
3575+
DateTime now = DateTime.Now;
3576+
3577+
// In RowFilter we have a string containing only seconds,
3578+
// but in rows we have a DateTime which also contains milliseconds.
3579+
// The test would fail without this extra minute, when now.Millisecond is 0.
3580+
DateTime rowDate = now.AddMinutes(1);
35773581

35783582
for (int i = 0; i < 10; i++)
35793583
{
35803584
dr = dt.NewRow();
3581-
dr["StartDate"] = date.AddDays(i);
3585+
dr["StartDate"] = rowDate.AddDays(i);
35823586
dt.Rows.Add(dr);
35833587
}
35843588

35853589
DataView dv = dt.DefaultView;
35863590
dv.RowFilter = string.Format(CultureInfo.InvariantCulture,
35873591
"StartDate >= #{0}# and StartDate <= #{1}#",
3588-
DateTime.Now.AddDays(2),
3589-
DateTime.Now.AddDays(4));
3592+
now.AddDays(2),
3593+
now.AddDays(4));
35903594
Assert.Equal(10, dt.Rows.Count);
35913595

35923596
int expectedRowCount = 2;
35933597
if (dv.Count != expectedRowCount)
35943598
{
35953599
StringBuilder sb = new();
3596-
sb.AppendLine($"DataView.Rows.Count: Expected: {expectedRowCount}, Actual: {dv.Count}. Debug data: RowFilter: {dv.RowFilter}, date: {date}");
3600+
sb.AppendLine($"DataView.Rows.Count: Expected: {expectedRowCount}, Actual: {dv.Count}. Debug data: RowFilter: {dv.RowFilter}, date: {now}");
35973601
for (int i = 0; i < dv.Count; i++)
35983602
{
35993603
sb.Append($"row#{i}: ");

0 commit comments

Comments
 (0)