Skip to content

Commit cdffbd8

Browse files
committed
address PR comments on slice unit tests
1 parent 361223d commit cdffbd8

File tree

1 file changed

+24
-57
lines changed

1 file changed

+24
-57
lines changed

Cql/CoreTests/PrimitiveTests.cs

Lines changed: 24 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -3725,15 +3725,14 @@ public void Subtract_Decimal_To_MinDecimal()
37253725
Assert.IsNull(subtractedValue);
37263726
}
37273727

3728-
#region Slice tests
3728+
#region Slice tests
37293729

37303730
/* Refer http://cql.hl7.org/09-b-cqlreference.html for operation details on Skip, Tail and Take cql operators
37313731
* These CQL operators uses Slice semantics from http://cql.hl7.org/04-logicalspecification.html#slice
37323732
*/
37333733

3734-
[TestCategory("SliceTests")]
37353734
[TestMethod]
3736-
public void Skip2()
3735+
public void Slice_Skip2()
37373736
{
37383737
//The Skip operator returns the elements in the list, skipping the first number elements.
37393738
//define "Skip2": Skip({ 1, 2, 3, 4, 5 }, 2) // { 3, 4, 5 }
@@ -3745,9 +3744,8 @@ public void Skip2()
37453744
CollectionAssert.AreEqual(expectedList, slicedList.ToList());
37463745
}
37473746

3748-
[TestCategory("SliceTests")]
37493747
[TestMethod]
3750-
public void SkipNull()
3748+
public void Slice_SkipNull()
37513749
{
37523750
//If the number of elements is null, the result is the entire list, no elements are skipped.
37533751
//define "SkipNull": Skip({ 1, 3, 5 }, null) // { 1, 3, 5 }
@@ -3758,10 +3756,9 @@ public void SkipNull()
37583756
Assert.IsNotNull(slicedList);
37593757
CollectionAssert.AreEqual(expectedList, slicedList.ToList());
37603758
}
3761-
3762-
[TestCategory("SliceTests")]
3759+
37633760
[TestMethod]
3764-
public void SkipEmpty()
3761+
public void Slice_SkipEmpty()
37653762
{
37663763
//If the number of elements is less than zero, the result is an empty list.
37673764
//define "SkipEmpty": Skip({ 1, 3, 5 }, -1) // { }
@@ -3772,10 +3769,9 @@ public void SkipEmpty()
37723769
Assert.IsNotNull(slicedList);
37733770
CollectionAssert.AreEqual(expectedList, slicedList.ToList());
37743771
}
3775-
3776-
[TestCategory("SliceTests")]
3772+
37773773
[TestMethod]
3778-
public void SkipIsNull()
3774+
public void Slice_SkipIsNull()
37793775
{
37803776
//If the source list is null, the result is null.
37813777
//define "SkipIsNull": Skip(null, 2)
@@ -3784,11 +3780,11 @@ public void SkipIsNull()
37843780
var expectedList = null as List<int>;
37853781
var slicedList = rtx.Operators.Slice(inputList, 2, null);
37863782
Assert.IsNull(slicedList);
3783+
Assert.AreEqual(expectedList, slicedList);
37873784
}
3788-
3789-
[TestCategory("SliceTests")]
3785+
37903786
[TestMethod]
3791-
public void Tail234()
3787+
public void Slice_Tail234()
37923788
{
37933789
//The Tail operator returns all but the first element from the given list.
37943790
//define "Tail234": Tail({ 1, 2, 3, 4 }) // { 2, 3, 4 }
@@ -3799,10 +3795,9 @@ public void Tail234()
37993795
Assert.IsNotNull(slicedList);
38003796
CollectionAssert.AreEqual(expectedList, slicedList.ToList());
38013797
}
3802-
3803-
[TestCategory("SliceTests")]
3798+
38043799
[TestMethod]
3805-
public void TailEmpty()
3800+
public void Slice_TailEmpty()
38063801
{
38073802
//If the list is empty, the result is empty.
38083803
//define "TailEmpty": Tail({ }) // { }
@@ -3813,10 +3808,9 @@ public void TailEmpty()
38133808
Assert.IsNotNull(slicedList);
38143809
CollectionAssert.AreEqual(expectedList, slicedList.ToList());
38153810
}
3816-
3817-
[TestCategory("SliceTests")]
3811+
38183812
[TestMethod]
3819-
public void TailIsNull()
3813+
public void Slice_TailIsNull()
38203814
{
38213815
//If the source list is null, the result is null.
38223816
//define "TailIsNull": Tail(null)
@@ -3825,11 +3819,11 @@ public void TailIsNull()
38253819
var expectedList = null as List<int>;
38263820
var slicedList = rtx.Operators.Slice(inputList, 1, null);
38273821
Assert.IsNull(slicedList);
3822+
Assert.AreEqual(expectedList, slicedList);
38283823
}
3829-
3830-
[TestCategory("SliceTests")]
3824+
38313825
[TestMethod]
3832-
public void Take2()
3826+
public void Slice_Take2()
38333827
{
38343828
//The Take operator returns the first number elements from the given list.
38353829
//define "Take2": Take({ 1, 2, 3, 4 }, 2) // { 1, 2 }
@@ -3840,10 +3834,9 @@ public void Take2()
38403834
Assert.IsNotNull(slicedList);
38413835
CollectionAssert.AreEqual(expectedList, slicedList.ToList());
38423836
}
3843-
3844-
[TestCategory("SliceTests")]
3837+
38453838
[TestMethod]
3846-
public void TakeTooMany()
3839+
public void Slice_TakeTooMany()
38473840
{
38483841
//If the list has less than number elements, the result only contains the elements in the list.
38493842
//define "TakeTooMany": Take({ 1, 2 }, 3) // { 1, 2 }
@@ -3854,10 +3847,9 @@ public void TakeTooMany()
38543847
Assert.IsNotNull(slicedList);
38553848
CollectionAssert.AreEqual(expectedList, slicedList.ToList());
38563849
}
3857-
3858-
[TestCategory("SliceTests")]
3850+
38593851
[TestMethod]
3860-
public void TakeEmpty()
3852+
public void Slice_TakeEmpty()
38613853
{
38623854
//If number is null, or 0 or less, the result is an empty list.
38633855
//define "TakeEmpty": Take({ 1, 2, 3, 4 }, null) // { }
@@ -3868,10 +3860,9 @@ public void TakeEmpty()
38683860
Assert.IsNotNull(slicedList);
38693861
CollectionAssert.AreEqual(expectedList, slicedList.ToList());
38703862
}
3871-
3872-
[TestCategory("SliceTests")]
3863+
38733864
[TestMethod]
3874-
public void TakeIsNull()
3865+
public void Slice_TakeIsNull()
38753866
{
38763867
//If the source list is null, the result is null.
38773868
//define "TakeIsNull": Take(null, 2)
@@ -3880,33 +3871,9 @@ public void TakeIsNull()
38803871
var expectedList = null as List<int>;
38813872
var slicedList = rtx.Operators.Slice(inputList, 0, 2);
38823873
Assert.IsNull(slicedList);
3874+
Assert.AreEqual(expectedList, slicedList);
38833875
}
38843876

3885-
[TestCategory("SliceTests")]
3886-
[TestMethod]
3887-
public void Slice_array_source()
3888-
{
3889-
//Testing array as a source for Slice operator
3890-
var rtx = GetNewContext();
3891-
var inputSource = new[] { 1, 2, 3, 4 };
3892-
var expectedList = new List<int> { 1, 2 };
3893-
var slicedList = rtx.Operators.Slice(inputSource, 0, 2);
3894-
Assert.IsNotNull(slicedList);
3895-
CollectionAssert.AreEqual(expectedList, slicedList.ToList());
3896-
}
3897-
3898-
[TestCategory("SliceTests")]
3899-
[TestMethod]
3900-
public void Slice_linkedList_source()
3901-
{
3902-
// Testing LinkedList as a source for Slice operator
3903-
var rtx = GetNewContext();
3904-
var inputSource = new LinkedList<int>(new[] { 1, 2, 3, 4 });
3905-
var expectedList = new List<int> { 1, 2 };
3906-
var slicedList = rtx.Operators.Slice(inputSource, 0, 2);
3907-
Assert.IsNotNull(slicedList);
3908-
CollectionAssert.AreEqual(expectedList, slicedList.ToList());
3909-
}
39103877
#endregion
39113878
}
39123879
}

0 commit comments

Comments
 (0)