Skip to content

Commit 4bc77a6

Browse files
committed
fix some tests failures
1 parent a0d526d commit 4bc77a6

File tree

2 files changed

+75
-9
lines changed

2 files changed

+75
-9
lines changed

tests/MongoDB.Driver.Tests/Linq/Linq3Implementation/Translators/ExpressionToAggregationExpressionTranslators/MethodTranslators/WindowMethodToAggregationExpressionTranslatorTests.cs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1491,6 +1491,8 @@ public void Translate_should_return_expected_result_for_Max()
14911491
[Fact]
14921492
public void Translate_should_return_expected_result_for_Median_with_Decimal()
14931493
{
1494+
RequireServer.Check().Supports(Feature.PercentileOperator);
1495+
14941496
var collection = Fixture.Collection;
14951497

14961498
var aggregate = collection.Aggregate()
@@ -1510,6 +1512,8 @@ public void Translate_should_return_expected_result_for_Median_with_Decimal()
15101512
[Fact]
15111513
public void Translate_should_return_expected_result_for_Median_with_Double()
15121514
{
1515+
RequireServer.Check().Supports(Feature.PercentileOperator);
1516+
15131517
var collection = Fixture.Collection;
15141518

15151519
var aggregate = collection.Aggregate()
@@ -1529,6 +1533,8 @@ public void Translate_should_return_expected_result_for_Median_with_Double()
15291533
[Fact]
15301534
public void Translate_should_return_expected_result_for_Median_with_Int32()
15311535
{
1536+
RequireServer.Check().Supports(Feature.PercentileOperator);
1537+
15321538
var collection = Fixture.Collection;
15331539

15341540
var aggregate = collection.Aggregate()
@@ -1548,6 +1554,8 @@ public void Translate_should_return_expected_result_for_Median_with_Int32()
15481554
[Fact]
15491555
public void Translate_should_return_expected_result_for_Median_with_Int64()
15501556
{
1557+
RequireServer.Check().Supports(Feature.PercentileOperator);
1558+
15511559
var collection = Fixture.Collection;
15521560

15531561
var aggregate = collection.Aggregate()
@@ -1567,6 +1575,8 @@ public void Translate_should_return_expected_result_for_Median_with_Int64()
15671575
[Fact]
15681576
public void Translate_should_return_expected_result_for_Median_with_nullable_Decimal()
15691577
{
1578+
RequireServer.Check().Supports(Feature.PercentileOperator);
1579+
15701580
var collection = Fixture.Collection;
15711581

15721582
var aggregate = collection.Aggregate()
@@ -1586,6 +1596,8 @@ public void Translate_should_return_expected_result_for_Median_with_nullable_Dec
15861596
[Fact]
15871597
public void Translate_should_return_expected_result_for_Median_with_nullable_Double()
15881598
{
1599+
RequireServer.Check().Supports(Feature.PercentileOperator);
1600+
15891601
var collection = Fixture.Collection;
15901602

15911603
var aggregate = collection.Aggregate()
@@ -1605,6 +1617,8 @@ public void Translate_should_return_expected_result_for_Median_with_nullable_Dou
16051617
[Fact]
16061618
public void Translate_should_return_expected_result_for_Median_with_nullable_Int32()
16071619
{
1620+
RequireServer.Check().Supports(Feature.PercentileOperator);
1621+
16081622
var collection = Fixture.Collection;
16091623

16101624
var aggregate = collection.Aggregate()
@@ -1624,6 +1638,8 @@ public void Translate_should_return_expected_result_for_Median_with_nullable_Int
16241638
[Fact]
16251639
public void Translate_should_return_expected_result_for_Median_with_nullable_Int64()
16261640
{
1641+
RequireServer.Check().Supports(Feature.PercentileOperator);
1642+
16271643
var collection = Fixture.Collection;
16281644

16291645
var aggregate = collection.Aggregate()
@@ -1643,6 +1659,8 @@ public void Translate_should_return_expected_result_for_Median_with_nullable_Int
16431659
[Fact]
16441660
public void Translate_should_return_expected_result_for_Median_with_window()
16451661
{
1662+
RequireServer.Check().Supports(Feature.PercentileOperator);
1663+
16461664
var collection = Fixture.Collection;
16471665

16481666
var aggregate = collection.Aggregate()
@@ -1688,6 +1706,8 @@ public void Translate_should_return_expected_result_for_Min()
16881706
[Fact]
16891707
public void Translate_should_return_expected_result_for_Percentile_with_Decimal()
16901708
{
1709+
RequireServer.Check().Supports(Feature.PercentileOperator);
1710+
16911711
var collection = Fixture.Collection;
16921712

16931713
var aggregate = collection.Aggregate()
@@ -1707,6 +1727,8 @@ public void Translate_should_return_expected_result_for_Percentile_with_Decimal(
17071727
[Fact]
17081728
public void Translate_should_return_expected_result_for_Percentile_with_Double()
17091729
{
1730+
RequireServer.Check().Supports(Feature.PercentileOperator);
1731+
17101732
var collection = Fixture.Collection;
17111733

17121734
var aggregate = collection.Aggregate()
@@ -1726,6 +1748,8 @@ public void Translate_should_return_expected_result_for_Percentile_with_Double()
17261748
[Fact]
17271749
public void Translate_should_return_expected_result_for_Percentile_with_Int32()
17281750
{
1751+
RequireServer.Check().Supports(Feature.PercentileOperator);
1752+
17291753
var collection = Fixture.Collection;
17301754

17311755
var aggregate = collection.Aggregate()
@@ -1745,6 +1769,8 @@ public void Translate_should_return_expected_result_for_Percentile_with_Int32()
17451769
[Fact]
17461770
public void Translate_should_return_expected_result_for_Percentile_with_Int64()
17471771
{
1772+
RequireServer.Check().Supports(Feature.PercentileOperator);
1773+
17481774
var collection = Fixture.Collection;
17491775

17501776
var aggregate = collection.Aggregate()
@@ -1764,6 +1790,8 @@ public void Translate_should_return_expected_result_for_Percentile_with_Int64()
17641790
[Fact]
17651791
public void Translate_should_return_expected_result_for_Percentile_with_nullable_Decimal()
17661792
{
1793+
RequireServer.Check().Supports(Feature.PercentileOperator);
1794+
17671795
var collection = Fixture.Collection;
17681796

17691797
var aggregate = collection.Aggregate()
@@ -1783,6 +1811,8 @@ public void Translate_should_return_expected_result_for_Percentile_with_nullable
17831811
[Fact]
17841812
public void Translate_should_return_expected_result_for_Percentile_with_nullable_Double()
17851813
{
1814+
RequireServer.Check().Supports(Feature.PercentileOperator);
1815+
17861816
var collection = Fixture.Collection;
17871817

17881818
var aggregate = collection.Aggregate()
@@ -1802,6 +1832,8 @@ public void Translate_should_return_expected_result_for_Percentile_with_nullable
18021832
[Fact]
18031833
public void Translate_should_return_expected_result_for_Percentile_with_nullable_Int32()
18041834
{
1835+
RequireServer.Check().Supports(Feature.PercentileOperator);
1836+
18051837
var collection = Fixture.Collection;
18061838

18071839
var aggregate = collection.Aggregate()
@@ -1821,6 +1853,8 @@ public void Translate_should_return_expected_result_for_Percentile_with_nullable
18211853
[Fact]
18221854
public void Translate_should_return_expected_result_for_Percentile_with_nullable_Int64()
18231855
{
1856+
RequireServer.Check().Supports(Feature.PercentileOperator);
1857+
18241858
var collection = Fixture.Collection;
18251859

18261860
var aggregate = collection.Aggregate()
@@ -1840,6 +1874,8 @@ public void Translate_should_return_expected_result_for_Percentile_with_nullable
18401874
[Fact]
18411875
public void Translate_should_return_expected_result_for_Percentile_with_multiple_percentiles()
18421876
{
1877+
RequireServer.Check().Supports(Feature.PercentileOperator);
1878+
18431879
var collection = Fixture.Collection;
18441880

18451881
var aggregate = collection.Aggregate()
@@ -1861,6 +1897,8 @@ public void Translate_should_return_expected_result_for_Percentile_with_multiple
18611897
[Fact]
18621898
public void Translate_should_return_expected_result_for_Percentile_with_window()
18631899
{
1900+
RequireServer.Check().Supports(Feature.PercentileOperator);
1901+
18641902
var collection = Fixture.Collection;
18651903

18661904
var aggregate = collection.Aggregate()
@@ -1887,6 +1925,8 @@ public void Translate_should_return_expected_result_for_Percentile_with_window()
18871925
[Fact]
18881926
public void Translate_should_return_expected_result_for_Percentile_with_List_input()
18891927
{
1928+
RequireServer.Check().Supports(Feature.PercentileOperator);
1929+
18901930
var collection = Fixture.Collection;
18911931
var percentiles = new List<double> { 0.25, 0.5, 0.75 };
18921932

tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationWithLinq2Tests/Translators/AggregateGroupTranslatorTests.cs

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -542,9 +542,7 @@ public void Should_translate_complex_selector()
542542
First = g.First().B,
543543
Last = g.Last().K,
544544
Min = g.Min(x => x.C.E.F + x.C.E.H),
545-
Max = g.Max(x => x.C.E.F + x.C.E.H),
546-
Median = g.Median(x => x.C.E.F + x.C.E.H),
547-
Percentile = g.Percentile(x => x.C.E.F + x.C.E.H, new[] { 0.95 })
545+
Max = g.Max(x => x.C.E.F + x.C.E.H)
548546
});
549547

550548
AssertStages(
@@ -558,9 +556,7 @@ public void Should_translate_complex_selector()
558556
__agg2 : { $first : '$B' },
559557
__agg3 : { $last : '$K' },
560558
__agg4 : { $min : { $add : ['$C.E.F', '$C.E.H'] } },
561-
__agg5 : { $max : { $add : ['$C.E.F', '$C.E.H'] } },
562-
__agg6 : { $median : { input : { $add : ['$C.E.F', '$C.E.H'] }, method : 'approximate' } },
563-
__agg7 : { $percentile : { input : { $add : ['$C.E.F', '$C.E.H'] }, p : [0.95], method : 'approximate' } }
559+
__agg5 : { $max : { $add : ['$C.E.F', '$C.E.H'] } }
564560
}
565561
}",
566562
@"
@@ -571,9 +567,7 @@ public void Should_translate_complex_selector()
571567
First : '$__agg2',
572568
Last : '$__agg3',
573569
Min : '$__agg4',
574-
Max : '$__agg5',
575-
Median : '$__agg6',
576-
Percentile : '$__agg7',
570+
Max : '$__agg5'
577571
_id : 0
578572
}
579573
}");
@@ -584,6 +578,38 @@ public void Should_translate_complex_selector()
584578
result.Value.Last.Should().Be(false);
585579
result.Value.Min.Should().Be(333);
586580
result.Value.Max.Should().Be(333);
581+
}
582+
583+
[Fact]
584+
public void Should_translate_complex_selector_with_quantile_methods()
585+
{
586+
RequireServer.Check().Supports(Feature.PercentileOperator);
587+
588+
var result = Group(x => x.A, g => new
589+
{
590+
Median = g.Median(x => x.C.E.F + x.C.E.H),
591+
Percentile = g.Percentile(x => x.C.E.F + x.C.E.H, new[] { 0.95 })
592+
});
593+
594+
AssertStages(
595+
result.Stages,
596+
@"
597+
{
598+
$group : {
599+
_id : '$A',
600+
__agg0 : { $median : { input : { $add : ['$C.E.F', '$C.E.H'] }, method : 'approximate' } },
601+
__agg1 : { $percentile : { input : { $add : ['$C.E.F', '$C.E.H'] }, p : [0.95], method : 'approximate' } }
602+
}
603+
}",
604+
@"
605+
{
606+
$project : {
607+
Median : '$__agg0',
608+
Percentile : '$__agg1',
609+
_id : 0
610+
}
611+
}");
612+
587613
result.Value.Median.Should().Be(333);
588614
result.Value.Percentile.Should().Equal(333);
589615
}

0 commit comments

Comments
 (0)