Skip to content

Commit 8db3363

Browse files
committed
CSHARP-4328: Code review changes.
1 parent dd0cae3 commit 8db3363

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp4328Tests.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,22 @@
1616
using System;
1717
using System.Linq;
1818
using FluentAssertions;
19+
using MongoDB.Bson;
1920
using MongoDB.Driver.Linq;
2021
using Xunit;
2122

2223
namespace MongoDB.Driver.Tests.Linq.Linq3ImplementationTests.Jira
2324
{
2425
public class CSharp4328Tests : Linq3IntegrationTest
2526
{
26-
[Fact]
27-
public void Filter_using_First_should_work()
27+
[Theory]
28+
[InlineData(null)]
29+
[InlineData("USA")]
30+
public void Filter_using_First_should_work(string country)
2831
{
2932
var collection = CreateCollection();
3033
var startTargetDeliveryDate = new DateTime(2022, 1, 1, 0, 0, 0, DateTimeKind.Utc);
3134
var endTargetDeliveryDate = new DateTime(2022, 12, 31, 0, 0, 0, DateTimeKind.Utc);
32-
var country = "USA";
3335

3436
var filterBuilder = Builders<SubscriptionRepositorySubscriptionModel>.Filter;
3537
var statusFilter = filterBuilder.Where(x => x.SubscriptionStatus == SubscriptionStatus.Active);
@@ -44,16 +46,20 @@ public void Filter_using_First_should_work()
4446
}
4547

4648
var renderedFilter = Translate(collection, filter);
47-
renderedFilter.Should().Be(
49+
var expectedFilter = BsonDocument.Parse(
4850
@"
4951
{
5052
SubscriptionStatus : 1,
5153
'UpcomingOrders.0.NextTargetDeliveryDate' : {
5254
$gte : ISODate('2022-01-01T00:00:00Z'),
5355
$lte : ISODate('2022-12-31T00:00:00Z')
54-
},
55-
'ShippingAddress.CountryCode' : 'USA'
56+
}
5657
}");
58+
if (!string.IsNullOrEmpty(country))
59+
{
60+
expectedFilter["ShippingAddress.CountryCode"] = country;
61+
}
62+
renderedFilter.Should().Be(expectedFilter);
5763

5864
var result = collection.Distinct(x => x.CustomerId, filter).ToList();
5965
result.Should().Equal(2);

0 commit comments

Comments
 (0)