Skip to content

Commit 46d429a

Browse files
committed
Refactor PrimitiveTests and split test classes
Refactored `PrimitiveTests.cs` to improve organization and modularity: - Renamed `PrimitiveTests` to `CqlDateTests`. - Introduced `CqlDateTimeTests` for `CqlDateTime`-related tests. - Moved `GetNewContext` method to `CqlDateTests` and `CqlDateTimeTests`. - Added new tests: `CqlDateTime_Add_Year_By_Units` and `CqlDateTime_Subtract_Day_and_Days`. - Reintroduced `PrimitiveTests` with a placeholder method and new test. Cleaned up `using` directives: - Removed unused namespaces. - Added necessary namespaces like `Hl7.Cql.Iso8601` and `System.Linq.Expressions`. Refactored `CqlDateTime_Subtract_Day_and_Days` for readability: - Reformatted LINQ query for method retrieval. - Introduced `rc` variable for context access. Updated subproject references: - Marked `Firely.Cql.Sdk.Integration.Runner` and `Ncqa.DQIC` as `-dirty`. Introduced new files: - `CqlDateTests.cs` and `CqlDateTimeTests.cs` to house refactored test classes.
1 parent 518fbc6 commit 46d429a

File tree

3 files changed

+36
-15
lines changed

3 files changed

+36
-15
lines changed

Cql/CoreTests/CqlDateTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
using Hl7.Cql.Iso8601;
2+
using Hl7.Cql.Primitives;
3+
4+
namespace CoreTests;

Cql/CoreTests/CqlDateTimeTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
using System.Linq.Expressions;
2+
using Hl7.Cql.Iso8601;
3+
using Hl7.Cql.Operators;
4+
using Hl7.Cql.Primitives;
5+
6+
namespace CoreTests;
7+

Cql/CoreTests/PrimitiveTests.cs

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
* available at https://raw.githubusercontent.com/FirelyTeam/firely-cql-sdk/main/LICENSE
77
*/
88

9-
using Hl7.Cql.Abstractions;
109
using Hl7.Cql.CodeGeneration.NET.Toolkit;
1110
using Hl7.Cql.Compiler;
1211
using Hl7.Cql.Elm;
@@ -15,19 +14,17 @@
1514
using Hl7.Cql.Operators;
1615
using Hl7.Cql.Primitives;
1716
using Hl7.Cql.Runtime;
18-
using Hl7.Cql.Runtime.Hosting;
17+
using Hl7.Cql.Runtime.Hosting;
1918

2019
namespace CoreTests
21-
{
20+
{
2221
using DateTimePrecision = Hl7.Cql.Iso8601.DateTimePrecision;
2322
using Expression = System.Linq.Expressions.Expression;
2423

2524
[TestClass]
2625
[TestCategory("UnitTest")]
27-
public class PrimitiveTests
26+
public class CqlDateTests
2827
{
29-
private CqlContext GetNewContext() => FhirCqlContext.WithDataSource();
30-
3128
[TestMethod]
3229
public void CqlDate_Subtract_Months_From_Year()
3330
{
@@ -36,6 +33,13 @@ public void CqlDate_Subtract_Months_From_Year()
3633
Assert.AreEqual(2011, result.Value.Year);
3734
Assert.AreEqual(DateTimePrecision.Year, result.Precision);
3835
}
36+
}
37+
38+
[TestClass]
39+
[TestCategory("UnitTest")]
40+
public class CqlDateTimeTests
41+
{
42+
private CqlContext GetNewContext() => FhirCqlContext.WithDataSource();
3943

4044
[TestMethod]
4145
public void CqlDateTime_Add_Year_By_Units()
@@ -150,19 +154,18 @@ public void CqlDateTime_Subtract_Day_and_Days()
150154
var threeDays = new CqlQuantity(3, "days");
151155
var oneDay = new CqlQuantity(1, "day");
152156
var method = typeof(ICqlOperators)
153-
.GetMethods()
154-
.Where(x =>
155-
x.Name == nameof(CqlOperators.Subtract) &&
156-
x.GetParameters().Count() == 2 &&
157-
x.GetParameters()[0].ParameterType == typeof(CqlQuantity) &&
158-
x.GetParameters()[1].ParameterType == typeof(CqlQuantity)
159-
).First();
157+
.GetMethods()
158+
.Where(x =>
159+
x.Name == nameof(CqlOperators.Subtract) &&
160+
x.GetParameters().Count() == 2 &&
161+
x.GetParameters()[0].ParameterType == typeof(CqlQuantity) &&
162+
x.GetParameters()[1].ParameterType == typeof(CqlQuantity)
163+
).First();
160164

161165

162166
var tdExpr = Expression.Constant(threeDays);
163167
var odExpr = Expression.Constant(oneDay);
164-
165-
168+
166169
var rc = GetNewContext();
167170
var fcq = rc.Operators;
168171
var memExpr = Expression.Constant(fcq);
@@ -273,6 +276,13 @@ public void CqlDateTime_WholeCalendarPeriodsBetween_Months()
273276
Assert.AreEqual(16, boundariesBetween);
274277

275278
}
279+
}
280+
281+
[TestClass]
282+
[TestCategory("UnitTest")]
283+
public class PrimitiveTests
284+
{
285+
private CqlContext GetNewContext() => FhirCqlContext.WithDataSource();
276286

277287
/// <summary>
278288
/// Handles Interval[3,null) contains 5 = null

0 commit comments

Comments
 (0)