Skip to content

Commit 894ac25

Browse files
committed
Fix tests that fail on Oracle
Basically they fail because they were written without oracle in mind. Some of them fail because of lack of feature check, others - because of bad design.
1 parent 59b8ba8 commit 894ac25

8 files changed

+85
-63
lines changed

Orm/Xtensive.Orm.Tests/Issues/IssueJira0221_UnableToTranslateAggregate.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
// Copyright (C) 2011 Xtensive LLC.
2-
// All rights reserved.
3-
// For conditions of distribution and use, see license.
1+
// Copyright (C) 2011-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: Denis Krjuchkov
55
// Created: 2011.11.21
66

77
using System.Linq;
88
using NUnit.Framework;
99
using Xtensive.Orm.Configuration;
10+
using Xtensive.Orm.Providers;
1011
using Xtensive.Orm.Tests.Issues.IssueJira0221_UnableToTranslateAggregateModel;
1112

1213
namespace Xtensive.Orm.Tests.Issues.IssueJira0221_UnableToTranslateAggregateModel
@@ -55,10 +56,12 @@ public override void TestFixtureSetUp()
5556

5657
CreateSessionAndTransaction();
5758

58-
new ZamesInfo {Owner = new Zames(), Rank = 1};
59-
new ZamesInfo {Owner = new Zames(), Rank = 3};
59+
_ = new ZamesInfo {Owner = new Zames(), Rank = 1};
60+
_ = new ZamesInfo {Owner = new Zames(), Rank = 3};
6061
}
6162

63+
protected override void CheckRequirements() => Require.AllFeaturesSupported(ProviderFeatures.ScalarSubqueries);
64+
6265
#region Min()
6366

6467
[Test]

Orm/Xtensive.Orm.Tests/Issues/IssueJira0240_SortingInSubqueryIsOmitted.cs

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
// Copyright (C) 2012 Xtensive LLC.
2-
// All rights reserved.
3-
// For conditions of distribution and use, see license.
1+
// Copyright (C) 2012-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: Denis Krjuchkov
55
// Created: 2012.01.25
66

77
using System;
88
using System.Linq;
99
using NUnit.Framework;
1010
using Xtensive.Orm.Configuration;
11+
using Xtensive.Orm.Providers;
1112
using Xtensive.Orm.Tests.Issues.IssueJira0240_SortingInSubqueryIsOmittedModel;
1213

1314
namespace Xtensive.Orm.Tests.Issues.IssueJira0240_SortingInSubqueryIsOmittedModel
@@ -43,32 +44,34 @@ public class IssueJira0240_SortingInSubqueryIsOmitted : AutoBuildTest
4344
protected override DomainConfiguration BuildConfiguration()
4445
{
4546
var configuration = base.BuildConfiguration();
46-
configuration.Types.Register(typeof (Container).Assembly, typeof (Container).Namespace);
47+
configuration.Types.Register(typeof(Container).Assembly, typeof(Container).Namespace);
4748
return configuration;
4849
}
4950

5051
protected override void PopulateData()
5152
{
52-
using (Domain.OpenSession())
53-
using (var tx = Session.Current.OpenTransaction()) {
53+
using (var session = Domain.OpenSession())
54+
using (var tx = session.OpenTransaction()) {
5455
var c = new Container();
55-
new StoredContainer {Container = c, CreationTime = new DateTime(2012, 1, 1), Address = "1"};
56-
new StoredContainer {Container = c, CreationTime = new DateTime(2012, 1, 2), Address = "2"};
57-
new StoredContainer {Container = c, CreationTime = new DateTime(2012, 1, 3), Address = "3"};
56+
_ = new StoredContainer { Container = c, CreationTime = new DateTime(2012, 1, 1), Address = "1" };
57+
_ = new StoredContainer { Container = c, CreationTime = new DateTime(2012, 1, 2), Address = "2" };
58+
_ = new StoredContainer { Container = c, CreationTime = new DateTime(2012, 1, 3), Address = "3" };
5859
tx.Complete();
5960
}
6061
}
6162

6263
[Test]
6364
public void MainTest()
6465
{
65-
using (Domain.OpenSession())
66-
using (var tx = Session.Current.OpenTransaction()) {
67-
var r = Query.All<Container>()
66+
Require.AllFeaturesSupported(ProviderFeatures.ScalarSubqueries);
67+
68+
using (var session = Domain.OpenSession())
69+
using (var tx = session.OpenTransaction()) {
70+
var r = session.Query.All<Container>()
6871
.Select(c => new {
6972
c.Id,
7073
LastLocation = Query.All<StoredContainer>()
71-
.Where(s => s.Container==c)
74+
.Where(s => s.Container == c)
7275
.OrderByDescending(s => s.CreationTime)
7376
.Select(s => s.Address)
7477
.FirstOrDefault()
@@ -84,10 +87,10 @@ public void RegressionTest()
8487
{
8588
using (var session = Domain.OpenSession())
8689
using (var tx = session.OpenTransaction()) {
87-
var container = Query.All<Container>().Single();
90+
var container = session.Query.All<Container>().Single();
8891
var now = DateTime.Now;
89-
var lastStoredContainer = Query.All<StoredContainer>()
90-
.Where(s => s.Container==container && s.CreationTime <= now)
92+
var lastStoredContainer = session.Query.All<StoredContainer>()
93+
.Where(s => s.Container == container && s.CreationTime <= now)
9194
.GroupBy(s => s.CreationTime)
9295
.OrderByDescending(s => s.Key)
9396
.FirstOrDefault();

Orm/Xtensive.Orm.Tests/Issues/IssueJira0443_FirstOrDefaultInSubqueryUsesWrongDefault.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
// Copyright (C) 2013 Xtensive LLC.
2-
// All rights reserved.
3-
// For conditions of distribution and use, see license.
1+
// Copyright (C) 2013-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: Denis Krjuchkov
55
// Created: 2013.04.30
66

77
using System.Linq;
88
using NUnit.Framework;
99
using Xtensive.Orm.Configuration;
10+
using Xtensive.Orm.Providers;
1011
using Xtensive.Orm.Tests.Issues.IssueJira0443_FirstOrDefaultInSubqueryUsesWrongDefaultModel;
1112

1213
namespace Xtensive.Orm.Tests.Issues
@@ -53,6 +54,8 @@ protected override DomainConfiguration BuildConfiguration()
5354
return configuration;
5455
}
5556

57+
protected override void CheckRequirements() => Require.AllFeaturesSupported(ProviderFeatures.ScalarSubqueries);
58+
5659
protected override void PopulateData()
5760
{
5861
using (var session = Domain.OpenSession())

Orm/Xtensive.Orm.Tests/Issues/IssueJira0446_TypeAsOnSubqueryOperand.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
// Copyright (C) 2013 Xtensive LLC.
2-
// All rights reserved.
3-
// For conditions of distribution and use, see license.
1+
// Copyright (C) 2013-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: Denis Krjuchkov
55
// Created: 2013.06.25
66

77
using System.Linq;
88
using NUnit.Framework;
99
using Xtensive.Orm.Configuration;
10+
using Xtensive.Orm.Providers;
1011
using Xtensive.Orm.Tests.Issues.IssueJira0446_TypeAsOnSubqueryOperandModel;
1112

1213
namespace Xtensive.Orm.Tests.Issues
@@ -46,10 +47,12 @@ public class IssueJira0446_TypeAsOnSubqueryOperand : AutoBuildTest
4647
protected override DomainConfiguration BuildConfiguration()
4748
{
4849
var configuration = base.BuildConfiguration();
49-
configuration.Types.Register(typeof (Owner).Assembly, typeof (Owner).Namespace);
50+
configuration.Types.Register(typeof(Owner).Assembly, typeof(Owner).Namespace);
5051
return configuration;
5152
}
5253

54+
protected override void CheckRequirements() => Require.AllFeaturesSupported(ProviderFeatures.ScalarSubqueries);
55+
5356
[Test]
5457
public void MainTest()
5558
{

Orm/Xtensive.Orm.Tests/Issues/IssueJira0449_TimeSpanMinMaxValue.cs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// Copyright (C) 2013 Xtensive LLC.
2-
// All rights reserved.
3-
// For conditions of distribution and use, see license.
1+
// Copyright (C) 2013-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: Denis Krjuchkov
55
// Created: 2013.07.02
66

@@ -36,17 +36,26 @@ protected override DomainConfiguration BuildConfiguration()
3636
}
3737

3838
[Test]
39-
public void MainTest()
39+
public void MinTest()
4040
{
41+
Require.ProviderIsNot(StorageProvider.Oracle, "Oracle has no resolution for TimeSpan.MinValue");
42+
4143
using (var session = Domain.OpenSession())
4244
using (var tx = session.OpenTransaction()) {
4345
var created = new EntityWithTimeSpan {Value = TimeSpan.MinValue};
44-
var fetched = session.Query.All<EntityWithTimeSpan>().Single(e => e.Value==TimeSpan.MinValue);
46+
var fetched = session.Query.All<EntityWithTimeSpan>().Single(e => e.Value == TimeSpan.MinValue);
4547
Assert.That(fetched, Is.EqualTo(created));
46-
created = new EntityWithTimeSpan {Value = TimeSpan.MaxValue};
47-
fetched = session.Query.All<EntityWithTimeSpan>().Single(e => e.Value==TimeSpan.MaxValue);
48+
}
49+
}
50+
51+
[Test]
52+
public void MaxTest()
53+
{
54+
using (var session = Domain.OpenSession())
55+
using (var tx = session.OpenTransaction()) {
56+
var created = new EntityWithTimeSpan { Value = TimeSpan.MaxValue };
57+
var fetched = session.Query.All<EntityWithTimeSpan>().Single(e => e.Value == TimeSpan.MaxValue);
4858
Assert.That(fetched, Is.EqualTo(created));
49-
tx.Complete();
5059
}
5160
}
5261
}

Orm/Xtensive.Orm.Tests/Issues/IssueJira0471_LikeOperatorSupport.cs

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// Copyright (C) 2013 Xtensive LLC.
2-
// All rights reserved.
3-
// For conditions of distribution and use, see license.
1+
// Copyright (C) 2013-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: Alexey Kulakov
55
// Created: 2013.08.12
66

@@ -79,9 +79,9 @@ where a.FirstName.Like("E!%ric", '!')
7979
}
8080

8181
[Test]
82-
public void AllInOneTest()
82+
public void AllInOneForSqlServerTest()
8383
{
84-
Require.ProviderIsNot(StorageProvider.Firebird);// specified escape character can't be used in firebird
84+
Require.ProviderIs(StorageProvider.SqlServer);
8585
using (var session = Domain.OpenSession())
8686
using (var transaction = session.OpenTransaction()) {
8787
var firstQuery = from a in session.Query.All<Customer>()
@@ -92,14 +92,14 @@ where a.LastName.Like("K!%![m%f_", '!')
9292
}
9393

9494
[Test]
95-
public void AllInOneForFirebirdTest()
95+
public void AllInOneTest()
9696
{
97-
Require.ProviderIs(StorageProvider.Firebird);
97+
Require.ProviderIsNot(StorageProvider.SqlServer);
9898
using (var session = Domain.OpenSession())
9999
using (var transaction = session.OpenTransaction()) {
100100
var firstQuery = from a in session.Query.All<Customer>()
101-
where a.LastName.Like("K$%[m%f_", '$')
102-
select a;
101+
where a.LastName.Like("K$%[m%f_", '$')
102+
select a;
103103
Assert.That(firstQuery.First().LastName, Is.EqualTo("K%[maroff"));
104104
}
105105
}
@@ -114,15 +114,14 @@ protected override DomainConfiguration BuildConfiguration()
114114
protected override void PopulateData()
115115
{
116116
using (var session = Domain.OpenSession())
117-
using (var transaction = session.OpenTransaction())
118-
{
119-
new Customer { FirstName = "Alexey", LastName = "Kulakov" };
120-
new Customer { FirstName = "Ulexey", LastName = "Kerzhakov" };
121-
new Customer { FirstName = "Klexey", LastName = "Komarov" };
122-
new Customer { FirstName = "Klexey", LastName = "K%[maroff" };
123-
new Customer { FirstName = "Martha", LastName = "$mith" };
124-
new Customer { FirstName = "E%ric", LastName = "Cartman" };
125-
new Customer { FirstName = "Kyle", LastName = "Broflovski" };
117+
using (var transaction = session.OpenTransaction()) {
118+
_ = new Customer { FirstName = "Alexey", LastName = "Kulakov" };
119+
_ = new Customer { FirstName = "Ulexey", LastName = "Kerzhakov" };
120+
_ = new Customer { FirstName = "Klexey", LastName = "Komarov" };
121+
_ = new Customer { FirstName = "Klexey", LastName = "K%[maroff" };
122+
_ = new Customer { FirstName = "Martha", LastName = "$mith" };
123+
_ = new Customer { FirstName = "E%ric", LastName = "Cartman" };
124+
_ = new Customer { FirstName = "Kyle", LastName = "Broflovski" };
126125
transaction.Complete();
127126
}
128127
}

Orm/Xtensive.Orm.Tests/Issues/IssueJira0627_PocoClassPropertyRenitialization.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2112,13 +2112,13 @@ public void UnionOfPocos05Test()
21122112
private void RequireProviderDeniesOrderByNull()
21132113
{
21142114
Require.ProviderIsNot(StorageProvider.Sqlite | StorageProvider.PostgreSql |
2115-
StorageProvider.MySql | StorageProvider.Firebird);
2115+
StorageProvider.MySql | StorageProvider.Firebird | StorageProvider.Oracle);
21162116
}
21172117

21182118
private void RequireProviderAllowsOrderByNull()
21192119
{
21202120
Require.ProviderIs(StorageProvider.Sqlite | StorageProvider.PostgreSql |
2121-
StorageProvider.MySql | StorageProvider.Firebird);
2121+
StorageProvider.MySql | StorageProvider.Firebird | StorageProvider.Oracle);
21222122
}
21232123
}
21242124
}

Orm/Xtensive.Orm.Tests/Issues/IssueJira0643_OracleDateTimeOffsetExtractionBug.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// Copyright (C) 2003-2016 Xtensive LLC.
2-
// All rights reserved.
3-
// For conditions of distribution and use, see license.
1+
// Copyright (C) 2016-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: Alexey Kulakov
55
// Created: 2016.04.29
66

@@ -53,19 +53,21 @@ public void MainTest()
5353
protected override void CheckRequirements()
5454
{
5555
Require.ProviderIs(StorageProvider.Oracle);
56-
Require.AllFeaturesSupported(ProviderFeatures.DateTimeOffset);
5756
}
5857

5958
protected override void PopulateData()
6059
{
60+
var baseDateTime = new DateTime(2020, 08, 18, 19, 20, 21, 22);
61+
var baseDateTimeOffset = new DateTimeOffset(baseDateTime, new TimeSpan(5, 0, 0));
62+
6163
dates = new DateTime[5];
6264
dateTimeOffsets = new DateTimeOffset[5];
6365
using (var session = Domain.OpenSession())
6466
using (var transaction = session.OpenTransaction()) {
6567
for (int i = 0; i < 5; i++) {
66-
new TestEntity {
67-
DateTimeField = dates[i] = DateTime.Now.AddHours(i),
68-
DateTimeOffsetField = dateTimeOffsets[i] = DateTimeOffset.Now.ToOffset(TimeSpan.FromHours(i))
68+
_ = new TestEntity {
69+
DateTimeField = dates[i] = baseDateTime.AddHours(i),
70+
DateTimeOffsetField = dateTimeOffsets[i] = baseDateTimeOffset.ToOffset(TimeSpan.FromHours(i))
6971
};
7072
}
7173
transaction.Complete();

0 commit comments

Comments
 (0)