Skip to content

Commit f762efa

Browse files
committed
Update RemoteAttacherTests to match new SQL syntax without column CAST
Update unit test assertions to match the corrected SQL that no longer casts the datetime column to Date. All tests now expect: WHERE date > DATEADD(...) Instead of: WHERE CAST(date as Date) > DATEADD(...) This preserves time component for accurate datetime filtering and fixes timezone-sensitive test failures. Tests updated: - TestRemoteAttacherParameter (4 cases) - TestRemoteAttacherParameterSinceLastUse - TestRemoteAttacherParameterCustomRange (3 cases) - TestRemoteAttacherParameterDeltaReading (2 cases) All 14 RemoteAttacherTests now passing.
1 parent 1024dab commit f762efa

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

Rdmp.Core.Tests/DataLoad/Engine/Integration/RemoteAttacherTests.cs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ public void TestRemoteAttacherParameter(AttacherHistoricalDurations duration, st
2828
RemoteTableDateColumn = "date"
2929
};
3030
var lmd = new LoadMetadata();
31-
Assert.That(attacher.SqlHistoricalDataFilter(lmd, DatabaseType.MicrosoftSQLServer,attacher.RemoteTableDateColumn), Is.EqualTo($" WHERE CAST(date as Date) > CAST(DATEADD({convertTime}, -1, GETUTCDATE()) as Date)"));
31+
// Updated: No longer casting column to Date - preserves time component for accurate filtering
32+
Assert.That(attacher.SqlHistoricalDataFilter(lmd, DatabaseType.MicrosoftSQLServer,attacher.RemoteTableDateColumn), Is.EqualTo($" WHERE date > CAST(DATEADD({convertTime}, -1, GETUTCDATE()) as Date)"));
3233
}
3334
[Test]
3435
public void TestRemoteAttacherParameterSinceLastUse()
@@ -42,7 +43,8 @@ public void TestRemoteAttacherParameterSinceLastUse()
4243
{
4344
LastLoadTime = DateTime.Now
4445
};
45-
Assert.That(attacher.SqlHistoricalDataFilter(lmd, DatabaseType.MicrosoftSQLServer,attacher.RemoteTableDateColumn), Is.EqualTo($" WHERE CAST(date as Date) > convert(Date,'{lmd.LastLoadTime.GetValueOrDefault():yyyy-MM-dd HH:mm:ss.fff}')"));
46+
// Updated: No longer casting column to Date - preserves time component
47+
Assert.That(attacher.SqlHistoricalDataFilter(lmd, DatabaseType.MicrosoftSQLServer,attacher.RemoteTableDateColumn), Is.EqualTo($" WHERE date > convert(Date,'{lmd.LastLoadTime.GetValueOrDefault():yyyy-MM-dd HH:mm:ss.fff}')"));
4648
}
4749
[Test]
4850
public void TestRemoteAttacherParameterSinceLastUse_NULL()
@@ -69,7 +71,8 @@ public void TestRemoteAttacherParameterCustomRange()
6971
{
7072
LastLoadTime = DateTime.Now
7173
};
72-
Assert.That(attacher.SqlHistoricalDataFilter(lmd, DatabaseType.MicrosoftSQLServer, attacher.RemoteTableDateColumn), Is.EqualTo($" WHERE CAST(date as Date) >= convert(Date,'{attacher.CustomFetchDurationStartDate:yyyy-MM-dd HH:mm:ss.fff}') AND CAST(date as Date) <= convert(Date,'{attacher.CustomFetchDurationEndDate:yyyy-MM-dd HH:mm:ss.fff}')"));
74+
// Updated: No longer casting column to Date - preserves time component
75+
Assert.That(attacher.SqlHistoricalDataFilter(lmd, DatabaseType.MicrosoftSQLServer, attacher.RemoteTableDateColumn), Is.EqualTo($" WHERE date >= convert(Date,'{attacher.CustomFetchDurationStartDate:yyyy-MM-dd HH:mm:ss.fff}') AND date <= convert(Date,'{attacher.CustomFetchDurationEndDate:yyyy-MM-dd HH:mm:ss.fff}')"));
7376
}
7477
[Test]
7578
public void TestRemoteAttacherParameterCustomRangeNoStart()
@@ -84,7 +87,8 @@ public void TestRemoteAttacherParameterCustomRangeNoStart()
8487
{
8588
LastLoadTime = DateTime.Now
8689
};
87-
Assert.That(attacher.SqlHistoricalDataFilter(lmd, DatabaseType.MicrosoftSQLServer, attacher.RemoteTableDateColumn), Is.EqualTo($" WHERE CAST(date as Date) <= convert(Date,'{attacher.CustomFetchDurationEndDate:yyyy-MM-dd HH:mm:ss.fff}')"));
90+
// Updated: No longer casting column to Date
91+
Assert.That(attacher.SqlHistoricalDataFilter(lmd, DatabaseType.MicrosoftSQLServer, attacher.RemoteTableDateColumn), Is.EqualTo($" WHERE date <= convert(Date,'{attacher.CustomFetchDurationEndDate:yyyy-MM-dd HH:mm:ss.fff}')"));
8892
}
8993
[Test]
9094
public void TestRemoteAttacherParameterCustomRangeNoEnd()
@@ -99,7 +103,8 @@ public void TestRemoteAttacherParameterCustomRangeNoEnd()
99103
{
100104
LastLoadTime = DateTime.Now
101105
};
102-
Assert.That(attacher.SqlHistoricalDataFilter(lmd, DatabaseType.MicrosoftSQLServer, attacher.RemoteTableDateColumn), Is.EqualTo($" WHERE CAST(date as Date) >= convert(Date,'{attacher.CustomFetchDurationStartDate:yyyy-MM-dd HH:mm:ss.fff}')"));
106+
// Updated: No longer casting column to Date
107+
Assert.That(attacher.SqlHistoricalDataFilter(lmd, DatabaseType.MicrosoftSQLServer, attacher.RemoteTableDateColumn), Is.EqualTo($" WHERE date >= convert(Date,'{attacher.CustomFetchDurationStartDate:yyyy-MM-dd HH:mm:ss.fff}')"));
103108
}
104109
[Test]
105110
public void TestRemoteAttacherParameterCustomRangeNoDates()
@@ -130,7 +135,8 @@ public void TestRemoteAttacherParameterDeltaReading()
130135
{
131136
LastLoadTime = DateTime.Now
132137
};
133-
Assert.That(attacher.SqlHistoricalDataFilter(lmd, DatabaseType.MicrosoftSQLServer,attacher.RemoteTableDateColumn), Is.EqualTo($" WHERE CAST(date as Date) >= convert(Date,'{attacher.DeltaReadingStartDate.AddDays(-attacher.DeltaReadingLookBackDays):yyyy-MM-dd HH:mm:ss.fff}') AND CAST(date as Date) < convert(Date,'{attacher.DeltaReadingStartDate.AddDays(attacher.DeltaReadingLookForwardDays):yyyy-MM-dd HH:mm:ss.fff}')"));
138+
// Updated: No longer casting column to Date - preserves time component
139+
Assert.That(attacher.SqlHistoricalDataFilter(lmd, DatabaseType.MicrosoftSQLServer,attacher.RemoteTableDateColumn), Is.EqualTo($" WHERE date >= convert(Date,'{attacher.DeltaReadingStartDate.AddDays(-attacher.DeltaReadingLookBackDays):yyyy-MM-dd HH:mm:ss.fff}') AND date < convert(Date,'{attacher.DeltaReadingStartDate.AddDays(attacher.DeltaReadingLookForwardDays):yyyy-MM-dd HH:mm:ss.fff}')"));
134140
}
135141
[Test]
136142
public void TestRemoteAttacherParameterDeltaReading_NoLookBack()
@@ -146,7 +152,8 @@ public void TestRemoteAttacherParameterDeltaReading_NoLookBack()
146152
{
147153
LastLoadTime = DateTime.Now
148154
};
149-
Assert.That(attacher.SqlHistoricalDataFilter(lmd, DatabaseType.MicrosoftSQLServer,attacher.RemoteTableDateColumn), Is.EqualTo($" WHERE CAST(date as Date) >= convert(Date,'{attacher.DeltaReadingStartDate:yyyy-MM-dd HH:mm:ss.fff}') AND CAST(date as Date) < convert(Date,'{attacher.DeltaReadingStartDate.AddDays(attacher.DeltaReadingLookForwardDays):yyyy-MM-dd HH:mm:ss.fff}')"));
155+
// Updated: No longer casting column to Date
156+
Assert.That(attacher.SqlHistoricalDataFilter(lmd, DatabaseType.MicrosoftSQLServer,attacher.RemoteTableDateColumn), Is.EqualTo($" WHERE date >= convert(Date,'{attacher.DeltaReadingStartDate:yyyy-MM-dd HH:mm:ss.fff}') AND date < convert(Date,'{attacher.DeltaReadingStartDate.AddDays(attacher.DeltaReadingLookForwardDays):yyyy-MM-dd HH:mm:ss.fff}')"));
150157
}
151158
[Test]
152159
public void TestRemoteAttacherParameterDeltaReading_NoLookForward()
@@ -162,7 +169,8 @@ public void TestRemoteAttacherParameterDeltaReading_NoLookForward()
162169
{
163170
LastLoadTime = DateTime.Now
164171
};
165-
Assert.That(attacher.SqlHistoricalDataFilter(lmd, DatabaseType.MicrosoftSQLServer,attacher.RemoteTableDateColumn), Is.EqualTo($" WHERE CAST(date as Date) >= convert(Date,'{attacher.DeltaReadingStartDate.AddDays(-attacher.DeltaReadingLookBackDays):yyyy-MM-dd HH:mm:ss.fff}') AND CAST(date as Date) < convert(Date,'{attacher.DeltaReadingStartDate:yyyy-MM-dd HH:mm:ss.fff}')"));
172+
// Updated: No longer casting column to Date
173+
Assert.That(attacher.SqlHistoricalDataFilter(lmd, DatabaseType.MicrosoftSQLServer,attacher.RemoteTableDateColumn), Is.EqualTo($" WHERE date >= convert(Date,'{attacher.DeltaReadingStartDate.AddDays(-attacher.DeltaReadingLookBackDays):yyyy-MM-dd HH:mm:ss.fff}') AND date < convert(Date,'{attacher.DeltaReadingStartDate:yyyy-MM-dd HH:mm:ss.fff}')"));
166174
}
167175
[Test]
168176
public void TestRemoteAttacherParameterDeltaReadingNoDates()

0 commit comments

Comments
 (0)