Skip to content

Commit e844c99

Browse files
committed
More tests fixed for Firebird
1 parent 09ec311 commit e844c99

3 files changed

Lines changed: 65 additions & 15 deletions

File tree

Orm/Xtensive.Orm.Tests/Linq/DistinctTest.cs

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
// Copyright (C) 2003-2010 Xtensive LLC.
2-
// All rights reserved.
3-
// For conditions of distribution and use, see license.
1+
// Copyright (C) 2009-2021 Xtensive LLC.
2+
// This code is distributed under MIT license terms.
3+
// See the License.txt file in the project root for more information.
44
// Created by: Alexis Kochetov
55
// Created: 2009.02.04
66

7+
using System;
78
using System.Linq;
89
using NUnit.Framework;
910
using Xtensive.Orm.Providers;
@@ -38,7 +39,22 @@ public void OrderBy2Test()
3839
.Select(c => c.Address.City)
3940
.Distinct()
4041
.OrderBy(c => c);
41-
Assert.IsTrue(expected.SequenceEqual(result));
42+
if (StorageProviderInfo.Instance.CheckProviderIs(StorageProvider.Firebird | StorageProvider.Sqlite)) {
43+
var storage = result.AsEnumerable().Where(c => !c.StartsWith('S'));
44+
var local = expected.Where(c => !c.StartsWith('S'));
45+
Assert.IsTrue(local.SequenceEqual(storage));
46+
var storageHashset = result.AsEnumerable().Where(c => c.StartsWith('S')).ToHashSet();
47+
local = expected.Where(c => c.StartsWith('S'));
48+
var count = 0;
49+
foreach (var item in local) {
50+
Assert.That(storageHashset.Contains(item));
51+
count++;
52+
}
53+
Assert.That(storageHashset.Count, Is.EqualTo(count));
54+
}
55+
else {
56+
Assert.IsTrue(expected.SequenceEqual(result));
57+
}
4258
QueryDumper.Dump(result);
4359
}
4460

@@ -95,7 +111,23 @@ public void DistinctOrderByTest()
95111
.Select(c => c.Address.City)
96112
.Distinct()
97113
.OrderBy(c => c);
98-
Assert.IsTrue(expected.SequenceEqual(result));
114+
115+
if (StorageProviderInfo.Instance.CheckProviderIs(StorageProvider.Firebird | StorageProvider.Sqlite)) {
116+
var storage = result.AsEnumerable().Where(c => !c.StartsWith('S'));
117+
var local = expected.Where(c => !c.StartsWith('S'));
118+
Assert.IsTrue(local.SequenceEqual(storage));
119+
var storageHashset = result.AsEnumerable().Where(c => c.StartsWith('S')).ToHashSet();
120+
local = expected.Where(c => c.StartsWith('S'));
121+
var count = 0;
122+
foreach (var item in local) {
123+
Assert.That(storageHashset.Contains(item));
124+
count++;
125+
}
126+
Assert.That(storageHashset.Count, Is.EqualTo(count));
127+
}
128+
else {
129+
Assert.IsTrue(expected.SequenceEqual(result));
130+
}
99131
QueryDumper.Dump(result);
100132
}
101133

@@ -316,6 +348,7 @@ public void DistinctSkipTest()
316348
.Distinct()
317349
.OrderBy(c => c.LastName)
318350
.Skip(5);
351+
319352
Assert.IsTrue(expected.SequenceEqual(result));
320353
Assert.Greater(result.ToList().Count, 0);
321354
}

Orm/Xtensive.Orm.Tests/Linq/OrderByTest.cs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
// Copyright (C) 2003-2010 Xtensive LLC.
2-
// All rights reserved.
3-
// For conditions of distribution and use, see license.
1+
// Copyright (C) 2009-2021 Xtensive LLC.
2+
// This code is distributed under MIT license terms.
3+
// See the License.txt file in the project root for more information.
44
// Created by: Dmitri Maximov
55
// Created: 2009.01.29
66

7+
using System;
78
using System.Collections.Generic;
89
using System.Linq;
910
using NUnit.Framework;
@@ -85,11 +86,11 @@ public void OrderByAnonymous2Test()
8586
{
8687
IQueryable<Customer> customers = Session.Query.All<Customer>();
8788
var result = customers
88-
.Select(c => new {c.Address.Country, c})
89+
.Select(c => new {c.SupportRep.EmployeeId, c})
8990
.OrderBy(x => x);
90-
var expected = customers.ToList()
91-
.Select(c => new {c.Address.Country, c})
92-
.OrderBy(x => x.Country)
91+
var expected = Customers
92+
.Select(c => new {c.SupportRep.EmployeeId, c})
93+
.OrderBy(x => x.EmployeeId)
9394
.ThenBy(x => x.c.CustomerId);
9495
Assert.That(result, Is.Not.Empty);
9596
Assert.IsTrue(expected.SequenceEqual(result));
@@ -308,10 +309,11 @@ public void SelectTest()
308309
[Test]
309310
public void ThenByTest()
310311
{
311-
var result = Session.Query.All<Customer>().OrderBy(c => c.Address.Country)
312+
var result = Session.Query.All<Customer>().OrderBy(c => c.SupportRep.EmployeeId)
312313
.ThenBy(c => c.Phone).Select(c => c.Address.City);
313-
var expected = Customers.OrderBy(c => c.Address.Country)
314+
var expected = Customers.OrderBy(c => c.SupportRep.EmployeeId)
314315
.ThenBy(c => c.Phone).Select(c => c.Address.City);
316+
315317
Assert.That(result, Is.Not.Empty);
316318
Assert.IsTrue(expected.SequenceEqual(result));
317319
}

Orm/Xtensive.Orm.Tests/Linq/SelectTest.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,13 +539,28 @@ from t in tracks
539539
[Test]
540540
public void NestedQueryTest()
541541
{
542+
Require.ProviderIsNot(StorageProvider.Firebird);
542543
var tracks = Session.Query.All<Track>();
543544
var result = from pd in
544545
from t in tracks
545546
select new { ProductKey = t.Key, t.Name, TotalPrice = t.UnitPrice * t.UnitPrice }
546-
where pd.TotalPrice > 100
547+
where pd.TotalPrice > 3.96005m
547548
select new { PKey = pd.ProductKey, pd.Name, Total = pd.TotalPrice };
548549

550+
var list = result.ToList(213);
551+
}
552+
553+
[Test]
554+
public void NestedQueryFirebirdTest()
555+
{
556+
Require.ProviderIs(StorageProvider.Firebird);
557+
var tracks = Session.Query.All<Track>();
558+
var result = from pd in
559+
from t in tracks
560+
select new { ProductKey = t.Key, t.Name, TotalPrice = t.UnitPrice + t.UnitPrice }
561+
where pd.TotalPrice > 3
562+
select new { PKey = pd.ProductKey, pd.Name, Total = pd.TotalPrice };
563+
549564
var list = result.ToList();
550565
}
551566

0 commit comments

Comments
 (0)