Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/LinqTests/Acceptance/Support/LinqTestContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ protected static void selectInOrder<T>(Func<IQueryable<Target>, IQueryable<T>> s
testCases.Add(comparison);
}

private static readonly string[] _methodNames = new string[] { "@where", nameof(ordered), nameof(unordered), nameof(selectInOrder), "select" };
private static readonly string[] _methodNames = ["@where", nameof(ordered), nameof(unordered), nameof(selectInOrder), "select"];
private static readonly string[] _descriptions;

protected static string[] readDescriptions()
Expand Down
2 changes: 1 addition & 1 deletion src/LinqTests/Acceptance/child_collection_queries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ protected async Task withData()
EmptyNumberArray.NumberArray = Array.Empty<int>();

HasNumberArray = targets[1];
HasNumberArray.NumberArray = new[] { 1, 2, 3 };
HasNumberArray.NumberArray = [1, 2, 3];

NullNumberArray = targets[2];
NullNumberArray.NumberArray = null;
Expand Down
6 changes: 3 additions & 3 deletions src/LinqTests/Acceptance/custom_identity_members.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Linq;
using System.Linq;
using System.Threading.Tasks;
using Marten;
using Marten.Testing.Harness;
Expand All @@ -8,8 +8,8 @@ namespace LinqTests.Acceptance;

public class custom_identity_members : OneOffConfigurationsContext
{
private static readonly string[] listIds = {"qwe", "zxc"};
private static readonly string[] listSystemIds = {"123", "456"};
private static readonly string[] listIds = ["qwe", "zxc"];
private static readonly string[] listSystemIds = ["123", "456"];

[Fact]
public async Task get_by_id_member_property()
Expand Down
8 changes: 4 additions & 4 deletions src/LinqTests/Acceptance/select_clause_usage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ public async Task use_select_in_query_for_one_field_and_first()
[Fact]
public async Task use_select_in_query_for_first_in_collection()
{
theSession.Store(new User { FirstName = "Hank", Roles = new []{"a", "b", "c"}});
theSession.Store(new User { FirstName = "Bill", Roles = new []{"d", "b", "c"} });
theSession.Store(new User { FirstName = "Sam", Roles = new []{"e", "b", "c"} });
theSession.Store(new User { FirstName = "Tom", Roles = new []{"f", "b", "c"} });
theSession.Store(new User { FirstName = "Hank", Roles = ["a", "b", "c"]});
theSession.Store(new User { FirstName = "Bill", Roles = ["d", "b", "c"] });
theSession.Store(new User { FirstName = "Sam", Roles = ["e", "b", "c"] });
theSession.Store(new User { FirstName = "Tom", Roles = ["f", "b", "c"] });

await theSession.SaveChangesAsync();

Expand Down
54 changes: 27 additions & 27 deletions src/LinqTests/Acceptance/select_many.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public class select_many : IntegrationContext
[Fact]
public async Task can_do_simple_select_many_against_simple_array()
{
var product1 = new Product {Tags = new[] {"a", "b", "c"}};
var product2 = new Product {Tags = new[] {"b", "c", "d"}};
var product3 = new Product {Tags = new[] {"d", "e", "f"}};
var product1 = new Product {Tags = ["a", "b", "c"]};
var product2 = new Product {Tags = ["b", "c", "d"]};
var product3 = new Product {Tags = ["d", "e", "f"]};

using (var session = theStore.LightweightSession())
{
Expand Down Expand Up @@ -124,9 +124,9 @@ public async Task can_do_simple_select_many_against_generic_list()
[Fact]
public async Task select_many_against_complex_type_with_count()
{
var product1 = new Product {Tags = new[] {"a", "b", "c"}};
var product2 = new Product {Tags = new[] {"b", "c", "d"}};
var product3 = new Product {Tags = new[] {"d", "e", "f"}};
var product1 = new Product {Tags = ["a", "b", "c"]};
var product2 = new Product {Tags = ["b", "c", "d"]};
var product3 = new Product {Tags = ["d", "e", "f"]};

using (var session = theStore.LightweightSession())
{
Expand All @@ -144,9 +144,9 @@ public async Task select_many_against_complex_type_with_count()
[Fact]
public async Task select_many_with_count_when_none_match_does_not_throw()
{
var product1 = new Product { Tags = new[] { "a", "b", "c" } };
var product2 = new Product { Tags = new[] { "b", "c", "d" } };
var product3 = new Product { Tags = new[] { "d", "e", "f" } };
var product1 = new Product { Tags = ["a", "b", "c"] };
var product2 = new Product { Tags = ["b", "c", "d"] };
var product3 = new Product { Tags = ["d", "e", "f"] };

using (var session = theStore.LightweightSession())
{
Expand All @@ -167,9 +167,9 @@ public async Task select_many_with_count_when_none_match_does_not_throw()
[Fact]
public async Task select_many_against_complex_type_with_count_async()
{
var product1 = new Product {Tags = new[] {"a", "b", "c"}};
var product2 = new Product {Tags = new[] {"b", "c", "d"}};
var product3 = new Product {Tags = new[] {"d", "e", "f"}};
var product1 = new Product {Tags = ["a", "b", "c"]};
var product2 = new Product {Tags = ["b", "c", "d"]};
var product3 = new Product {Tags = ["d", "e", "f"]};

await using (var session = theStore.LightweightSession())
{
Expand All @@ -187,9 +187,9 @@ public async Task select_many_against_complex_type_with_count_async()
[Fact]
public async Task select_many_with_count_when_none_match_does_not_throw_async()
{
var product1 = new Product { Tags = new[] { "a", "b", "c" } };
var product2 = new Product { Tags = new[] { "b", "c", "d" } };
var product3 = new Product { Tags = new[] { "d", "e", "f" } };
var product1 = new Product { Tags = ["a", "b", "c"] };
var product2 = new Product { Tags = ["b", "c", "d"] };
var product3 = new Product { Tags = ["d", "e", "f"] };

await using (var session = theStore.LightweightSession())
{
Expand Down Expand Up @@ -231,9 +231,9 @@ public async Task select_many_against_complex_type_without_transformation()
[Fact]
public async Task select_many_against_integer_array()
{
var product1 = new ProductWithNumbers {Tags = new[] {1, 2, 3}};
var product2 = new ProductWithNumbers {Tags = new[] {2, 3, 4}};
var product3 = new ProductWithNumbers {Tags = new[] {3, 4, 5}};
var product1 = new ProductWithNumbers {Tags = [1, 2, 3]};
var product2 = new ProductWithNumbers {Tags = [2, 3, 4]};
var product3 = new ProductWithNumbers {Tags = [3, 4, 5]};

using (var session = theStore.LightweightSession())
{
Expand All @@ -256,9 +256,9 @@ public async Task select_many_against_integer_array()
[Fact]
public async Task select_many_against_integer_array_async()
{
var product1 = new ProductWithNumbers {Tags = new[] {1, 2, 3}};
var product2 = new ProductWithNumbers {Tags = new[] {2, 3, 4}};
var product3 = new ProductWithNumbers {Tags = new[] {3, 4, 5}};
var product1 = new ProductWithNumbers {Tags = [1, 2, 3]};
var product2 = new ProductWithNumbers {Tags = [2, 3, 4]};
var product3 = new ProductWithNumbers {Tags = [3, 4, 5]};

await using (var session = theStore.LightweightSession())
{
Expand All @@ -281,9 +281,9 @@ public async Task select_many_against_integer_array_async()
[Fact]
public async Task select_many_with_any()
{
var product1 = new Product {Tags = new[] {"a", "b", "c"}};
var product2 = new Product {Tags = new[] {"b", "c", "d"}};
var product3 = new Product {Tags = new[] {"d", "e", "f"}};
var product1 = new Product {Tags = ["a", "b", "c"]};
var product2 = new Product {Tags = ["b", "c", "d"]};
var product3 = new Product {Tags = ["d", "e", "f"]};

using (var session = theStore.LightweightSession())
{
Expand Down Expand Up @@ -312,9 +312,9 @@ public async Task select_many_with_any_async()
{
await theStore.Advanced.Clean.DeleteDocumentsByTypeAsync(typeof(Target));

var product1 = new Product {Tags = new[] {"a", "b", "c"}};
var product2 = new Product {Tags = new[] {"b", "c", "d"}};
var product3 = new Product {Tags = new[] {"d", "e", "f"}};
var product1 = new Product {Tags = ["a", "b", "c"]};
var product2 = new Product {Tags = ["b", "c", "d"]};
var product3 = new Product {Tags = ["d", "e", "f"]};

await using (var session = theStore.LightweightSession())
{
Expand Down
4 changes: 2 additions & 2 deletions src/LinqTests/Bugs/Bug_1875_duplicated_array_field_test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public async Task query_on_duplicated_number_array_field_test()
{
session.Store(new Target
{
NumberArray = new []{ 1, 2 }
NumberArray = [1, 2]
});

await session.SaveChangesAsync();
Expand All @@ -42,7 +42,7 @@ public async Task query_on_duplicated_guid_array_field_test()
_.Schema.For<Target>().Duplicate(t => t.GuidArray, "uuid[]");
});

var target = new Target {GuidArray = new Guid[] {Guid.NewGuid(), Guid.NewGuid()}};
var target = new Target {GuidArray = [Guid.NewGuid(), Guid.NewGuid()]};

using (var session = theStore.LightweightSession())
{
Expand Down
12 changes: 6 additions & 6 deletions src/LinqTests/Bugs/Bug_1884_multi_tenancy_and_Any_query.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public async Task any_filter_honors_tenancy()
// Write some User documents to tenant "tenant1"
await using (var session = store.LightweightSession("tenant1"))
{
session.Store(new User { Id = "u1", UserName = "Bill", Roles = new[] { "admin" } });
session.Store(new User { Id = "u1", UserName = "Bill", Roles = ["admin"] });
session.Store(new User { Id = "u2", UserName = "Lindsey", Roles = [] });
await session.SaveChangesAsync();
}
Expand All @@ -41,7 +41,7 @@ public async Task any_filter_honors_tenancy()
await using (var session = store.LightweightSession("tenant2"))
{
session.Store(new User { Id = "u1", UserName = "Frank", Roles = [] });
session.Store(new User { Id = "u2", UserName = "Jill", Roles = new[] { "admin", "user" } });
session.Store(new User { Id = "u2", UserName = "Jill", Roles = ["admin", "user"] });
await session.SaveChangesAsync();
}

Expand All @@ -67,7 +67,7 @@ public async Task will_isolate_tenants_when_using_any_and_tenants_use_unique_ids
// Write some User documents to tenant "tenant1"
using (var session = theStore.LightweightSession("tenant1"))
{
session.Store(new User { Id = "u1", UserName = "Bill", Roles = new[] { "admin" } });
session.Store(new User { Id = "u1", UserName = "Bill", Roles = ["admin"] });
session.Store(new User { Id = "u2", UserName = "Lindsey", Roles = [] });
await session.SaveChangesAsync();
}
Expand All @@ -78,7 +78,7 @@ public async Task will_isolate_tenants_when_using_any_and_tenants_use_unique_ids
using (var session = theStore.LightweightSession("tenant2"))
{
session.Store(new User { Id = "u3", UserName = "Frank", Roles = [] });
session.Store(new User { Id = "u4", UserName = "Jill", Roles = new[] { "admin", "user" } });
session.Store(new User { Id = "u4", UserName = "Jill", Roles = ["admin", "user"] });
await session.SaveChangesAsync();
}

Expand Down Expand Up @@ -114,7 +114,7 @@ public async Task can_query_with_AnyTenant()
// Write some User documents to tenant "tenant1"
using (var session = theStore.LightweightSession("tenant1"))
{
session.Store(new User { Id = "u1", UserName = "Bill", Roles = new[] { "admin" } });
session.Store(new User { Id = "u1", UserName = "Bill", Roles = ["admin"] });
session.Store(new User { Id = "u2", UserName = "Lindsey", Roles = [] });
await session.SaveChangesAsync();
}
Expand All @@ -125,7 +125,7 @@ public async Task can_query_with_AnyTenant()
using (var session = theStore.LightweightSession("tenant2"))
{
session.Store(new User { Id = "u3", UserName = "Frank", Roles = [] });
session.Store(new User { Id = "u4", UserName = "Jill", Roles = new[] { "admin", "user" } });
session.Store(new User { Id = "u4", UserName = "Jill", Roles = ["admin", "user"] });
await session.SaveChangesAsync();
}

Expand Down
10 changes: 5 additions & 5 deletions src/LinqTests/Bugs/Bug_2563_sub_collection_queries_and_OR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ public async Task get_distinct_number()
theStore.Options.Schema.For<Bug2563Target>()
.Duplicate(x => x.UserIds);

theSession.Store(new Bug2563Target {Id = 1, IsPublic = false, UserIds = new [] { 1, 2, 3, 4, 5, 6 }});
theSession.Store(new Bug2563Target {Id = 1, IsPublic = false, UserIds = [1, 2, 3, 4, 5, 6]});
theSession.Store(new Bug2563Target {Id = 2, IsPublic = false, UserIds = [] });
theSession.Store(new Bug2563Target {Id = 3, IsPublic = true, UserIds = new [] { 1, 2, 3 }});
theSession.Store(new Bug2563Target {Id = 4, IsPublic = true, UserIds = new [] { 1, 2, 6 }});
theSession.Store(new Bug2563Target {Id = 5, IsPublic = false, UserIds = new [] { 4, 5, 6 }});
theSession.Store(new Bug2563Target {Id = 6, IsPublic = true, UserIds = new [] { 10 }});
theSession.Store(new Bug2563Target {Id = 3, IsPublic = true, UserIds = [1, 2, 3]});
theSession.Store(new Bug2563Target {Id = 4, IsPublic = true, UserIds = [1, 2, 6]});
theSession.Store(new Bug2563Target {Id = 5, IsPublic = false, UserIds = [4, 5, 6]});
theSession.Store(new Bug2563Target {Id = 6, IsPublic = true, UserIds = [10]});

await theSession.SaveChangesAsync();
theSession.Logger = new TestOutputMartenLogger(_output);
Expand Down
4 changes: 2 additions & 2 deletions src/LinqTests/Bugs/Bug_2618_Include_with_AnyTenant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public async Task tenant_filter_should_apply_to_both_parent_and_child_documents(
});

var user1a = new User();
var issue1a = new Issue { AssigneeId = user1a.Id, Tags = new[] { "DIY" }, Title = "Garage Door is busted" };
var issue1a = new Issue { AssigneeId = user1a.Id, Tags = ["DIY"], Title = "Garage Door is busted" };

await using (var session = theStore.LightweightSession("one"))
{
Expand All @@ -38,7 +38,7 @@ public async Task tenant_filter_should_apply_to_both_parent_and_child_documents(
}

var user2a = new User();
var issue2a = new Issue { AssigneeId = user2a.Id, Tags = new[] { "DIY" }, Title = "Garage Door is busted" };
var issue2a = new Issue { AssigneeId = user2a.Id, Tags = ["DIY"], Title = "Garage Door is busted" };


await using (var session = theStore.LightweightSession("two"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ public async Task try_to_query_on_contains_as_string()
{
StoreOptions(opts => opts.UseSystemTextJsonForSerialization(EnumStorage.AsString));

var doc1 = new MyDoc("one", new Colors[] { Colors.Blue, Colors.Green });
var doc2 = new MyDoc("two", new Colors[] { Colors.Blue, Colors.Red });
var doc3 = new MyDoc("three", new Colors[] { Colors.Orange, Colors.Yellow });
var doc1 = new MyDoc("one", [Colors.Blue, Colors.Green]);
var doc2 = new MyDoc("two", [Colors.Blue, Colors.Red]);
var doc3 = new MyDoc("three", [Colors.Orange, Colors.Yellow]);

theSession.Store(doc1, doc2, doc3);
await theSession.SaveChangesAsync();
Expand All @@ -38,9 +38,9 @@ public async Task try_to_query_on_contains_as_int()
{
StoreOptions(opts => opts.UseSystemTextJsonForSerialization(EnumStorage.AsInteger));

var doc1 = new MyDoc("one", new Colors[] { Colors.Blue, Colors.Green });
var doc2 = new MyDoc("two", new Colors[] { Colors.Blue, Colors.Red });
var doc3 = new MyDoc("three", new Colors[] { Colors.Orange, Colors.Yellow });
var doc1 = new MyDoc("one", [Colors.Blue, Colors.Green]);
var doc2 = new MyDoc("two", [Colors.Blue, Colors.Red]);
var doc3 = new MyDoc("three", [Colors.Orange, Colors.Yellow]);

theSession.Store(doc1, doc2, doc3);
await theSession.SaveChangesAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public async Task include_with_SingleOrDefault_where_for_a_single_document()
StoreOptions(opts => opts.Policies.AllDocumentsAreMultiTenanted());

var user = new User{Id = Guid.NewGuid()};
var issue = new Issue { AssigneeId = user.Id, Tags = new[] { "DIY" }, Title = "Garage Door is busted" };
var issue = new Issue { AssigneeId = user.Id, Tags = ["DIY"], Title = "Garage Door is busted" };

using (var session = theStore.LightweightSession("a"))
{
Expand All @@ -34,7 +34,7 @@ public async Task include_with_SingleOrDefault_where_for_a_single_document()
using (var session2 = theStore.LightweightSession("b"))
{
var user2 = new User{Id = user.Id};
var issue2 = new Issue { AssigneeId = user.Id, Tags = new[] { "DIY" }, Title = "Garage Door is busted" };
var issue2 = new Issue { AssigneeId = user.Id, Tags = ["DIY"], Title = "Garage Door is busted" };

session2.Store<object>(user2, issue2);
await session2.SaveChangesAsync();
Expand Down
16 changes: 8 additions & 8 deletions src/LinqTests/Bugs/Bug_561_negation_of_query_on_contains.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ public Bug_561_negation_of_query_on_contains(DefaultStoreFixture fixture) : base

protected override Task fixtureSetup()
{
var doc1 = new DocWithArrays { Strings = new string[] { "a", "b", "c" } };
var doc2 = new DocWithArrays { Strings = new string[] { "c", "d", "e" } };
var doc3 = new DocWithArrays { Strings = new string[] { "d", "e", "f" } };
var doc4 = new DocWithArrays { Strings = new string[] { "g", "h", "i" } };
var doc1 = new DocWithArrays { Strings = ["a", "b", "c"] };
var doc2 = new DocWithArrays { Strings = ["c", "d", "e"] };
var doc3 = new DocWithArrays { Strings = ["d", "e", "f"] };
var doc4 = new DocWithArrays { Strings = ["g", "h", "i"] };

theSession.Store(doc1, doc2, doc3, doc4);

Expand Down Expand Up @@ -59,10 +59,10 @@ public Bug_561_negation_of_query_on_contains_with_camel_casing()

public async Task InitializeAsync()
{
var doc1 = new DocWithArrays { Strings = new string[] { "a", "b", "c" } };
var doc2 = new DocWithArrays { Strings = new string[] { "c", "d", "e" } };
var doc3 = new DocWithArrays { Strings = new string[] { "d", "e", "f" } };
var doc4 = new DocWithArrays { Strings = new string[] { "g", "h", "i" } };
var doc1 = new DocWithArrays { Strings = ["a", "b", "c"] };
var doc2 = new DocWithArrays { Strings = ["c", "d", "e"] };
var doc3 = new DocWithArrays { Strings = ["d", "e", "f"] };
var doc4 = new DocWithArrays { Strings = ["g", "h", "i"] };

theSession.Store(doc1, doc2, doc3, doc4);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ public async Task do_not_blow_up_with_exceptions()
if (DateTime.Today < new DateTime(2023, 9, 12)) return;

var targets = Target.GenerateRandomData(100).ToArray();
targets[1].NumberArray = new[] {3, 4, 5};
targets[1].NumberArray = [3, 4, 5];
targets[1].Flag = true;

targets[5].NumberArray = new[] {3, 4, 5};
targets[5].NumberArray = [3, 4, 5];
targets[5].Flag = true;
targets[20].NumberArray = new[] {5, 6, 7};
targets[20].NumberArray = [5, 6, 7];
targets[20].Flag = true;


Expand Down
Loading
Loading