Skip to content

Commit 6dc744e

Browse files
committed
Some more async variants of existing .Store() tests
1 parent 1bb72d2 commit 6dc744e

2 files changed

Lines changed: 45 additions & 6 deletions

File tree

Orm/Xtensive.Orm.Tests/Linq/LocalCollectionsTest.cs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
using Xtensive.Orm.Tests.Linq.LocalCollectionsTest_Model;
1515
using Xtensive.Orm.Tests.ObjectModel;
1616
using Xtensive.Orm.Tests.ObjectModel.ChinookDO;
17+
using System.Threading.Tasks;
1718

1819
namespace Xtensive.Orm.Tests.Linq.LocalCollectionsTest_Model
1920
{
@@ -253,7 +254,7 @@ public void Pair2Test()
253254
[Test]
254255
public void Poco1Test()
255256
{
256-
Assert.Throws<QueryTranslationException>(() => {
257+
_ = Assert.Throws<QueryTranslationException>(() => {
257258
var pocos = Customers
258259
.Select(customer => new Poco<string>() { Value = customer.LastName })
259260
.ToList();
@@ -357,7 +358,7 @@ public void TypeLoop1Test()
357358
var nodes = new Node[10];
358359
var query = Session.Query.All<Invoice>()
359360
.Join(nodes, invoice => invoice.Customer.Address.City, node => node.Name, (invoice, node) => new {invoice, node});
360-
Assert.Throws<QueryTranslationException>(() => QueryDumper.Dump(query));
361+
_ = Assert.Throws<QueryTranslationException>(() => QueryDumper.Dump(query));
361362
}
362363

363364
[Test]
@@ -403,7 +404,7 @@ public void AllTest()
403404
[Test]
404405
public void KeyTest()
405406
{
406-
Assert.Throws<QueryTranslationException>( () => {
407+
_ = Assert.Throws<QueryTranslationException>(() => {
407408
var keys = Session.Query.All<Invoice>().Take(10).Select(invoice => invoice.Key).ToList();
408409
var query = Session.Query.All<Invoice>()
409410
.Join(keys, invoice => invoice.Key, key => key, (invoice, key) => new {invoice, key});
@@ -863,7 +864,6 @@ public void Aggregate1Test()
863864
Assert.AreEqual(result, expected);
864865
}
865866

866-
867867
[Test]
868868
public void Aggregate2Test()
869869
{
@@ -881,10 +881,27 @@ public void Aggregate2Test()
881881
QueryDumper.Dump(result);
882882
}
883883

884+
[Test]
885+
public async Task Aggregate2AsyncTest()
886+
{
887+
Require.AllFeaturesSupported(ProviderFeatures.TemporaryTables);
888+
Require.ProviderIsNot(StorageProvider.SqlServerCe);
889+
var localItems = GetLocalItems(100);
890+
var queryable = Session.Query.Store(localItems);
891+
var result = (await Session.Query.All<Invoice>()
892+
.Where(invoice => invoice.Commission > queryable.Max(poco => poco.Value2)).AsAsync()).ToList();
893+
var expected = Invoices
894+
.Where(invoice => invoice.Commission > localItems.Max(poco => poco.Value2));
895+
896+
Assert.That(result, Is.Not.Empty);
897+
Assert.AreEqual(0, expected.Except(result).Count());
898+
QueryDumper.Dump(result);
899+
}
900+
884901
[Test]
885902
public void ClosureCacheTest()
886903
{
887-
Assert.Throws<QueryTranslationException>( () => {
904+
_ = Assert.Throws<QueryTranslationException>( () => {
888905
var localItems = GetLocalItems(100);
889906
var queryable = Session.Query.Store(localItems);
890907
var result = Session.Query.Execute(qe => qe.All<Invoice>().Where(invoice => invoice.Commission > queryable.Max(poco => poco.Value2)));

Orm/Xtensive.Orm.Tests/Linq/QueryMethodTests.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public void Store1Test()
121121
}
122122

123123
[Test]
124-
public async Task Store1TestAsync()
124+
public async Task Store1AsyncTest()
125125
{
126126
Require.AllFeaturesSupported(ProviderFeatures.TemporaryTables);
127127

@@ -165,6 +165,28 @@ public void Store2Test()
165165
Assert.AreEqual(0, expected.Except(query).Count());
166166
}
167167

168+
[Test]
169+
public async Task Store2AsyncTest()
170+
{
171+
Require.AllFeaturesSupported(ProviderFeatures.TemporaryTables);
172+
173+
var query = (await Session.Query.All<Customer>()
174+
.Join(
175+
Session.Query.Store(Session.Query.All<Customer>().Take(10)),
176+
customer => customer,
177+
localCustomer => localCustomer,
178+
(customer, localCustomer) => new { customer, localCustomer }).AsAsync()).ToList();
179+
var expected = Session.Query.All<Customer>().AsEnumerable()
180+
.Join(
181+
Session.Query.Store(Session.Query.All<Customer>().Take(10)),
182+
customer => customer,
183+
localCustomer => localCustomer,
184+
(customer, localCustomer) => new { customer, localCustomer });
185+
186+
Assert.That(query, Is.Not.Empty);
187+
Assert.AreEqual(0, expected.Except(query).Count());
188+
}
189+
168190
private IEnumerable<Customer> GetExpectedCustomerAsSequence()
169191
{
170192
if (StorageProviderInfo.Instance.CheckProviderIs(StorageProvider.Firebird)) {

0 commit comments

Comments
 (0)