Skip to content

Commit fd9ea07

Browse files
committed
Main project tests improvements
1 parent 3627908 commit fd9ea07

38 files changed

Lines changed: 910 additions & 535 deletions

Orm/Xtensive.Orm.Tests/Issues/Issue0676_NonNullableReferenceBug.cs

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

Orm/Xtensive.Orm.Tests/Issues/IssueJira0208_IncorrectUpgradeSequence/UpgradeTest.cs

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

@@ -38,6 +38,7 @@ public void SetUp()
3838
}
3939

4040
[Test]
41+
[IgnoreIfGithubActions(StorageProvider.Firebird)]
4142
public void UpgradeToVersion2Test()
4243
{
4344
BuildDomain("2", DomainUpgradeMode.PerformSafely);

Orm/Xtensive.Orm.Tests/Issues/IssueJira0421_DateTimeAddXxx.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2013-2021 Xtensive LLC.
1+
// Copyright (C) 2013-2025 Xtensive LLC.
22
// This code is distributed under MIT license terms.
33
// See the License.txt file in the project root for more information.
44
// Created by: Denis Krjuchkov
@@ -79,15 +79,31 @@ private static void RunTest(Session session, Expression<Func<EntityWithDate, boo
7979
[Test]
8080
public void AddYearsTest()
8181
{
82+
Require.ProviderIsNot(StorageProvider.Firebird);
8283
RunAllTestsInt(value => e => e.Today.AddYears(value) == today.AddYears(value));
8384
}
8485

86+
[Test]
87+
public void AddYearsFirebirdTest()
88+
{
89+
Require.ProviderIs(StorageProvider.Firebird);
90+
RunAllTestsInt(value => e => e.Today.AddYears(value) == today.AddYears(value).AdjustDateTime(0, false));
91+
}
92+
8593
[Test]
8694
public void AddMonthsTest()
8795
{
96+
Require.ProviderIsNot(StorageProvider.Firebird);
8897
RunAllTestsInt(value => e => e.Today.AddMonths(value) == today.AddMonths(value));
8998
}
9099

100+
[Test]
101+
public void AddMonthsFirebirdTest()
102+
{
103+
Require.ProviderIs(StorageProvider.Firebird);
104+
RunAllTestsInt(value => e => e.Today.AddMonths(value) == today.AddMonths(value).AdjustDateTime(0, false));
105+
}
106+
91107
[Test]
92108
public void AddDaysTest()
93109
{

Orm/Xtensive.Orm.Tests/Issues/IssueJira0537_DropDefaultConstraintBugTest.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2013-2021 Xtensive LLC.
1+
// Copyright (C) 2013-2025 Xtensive LLC.
22
// This code is distributed under MIT license terms.
33
// See the License.txt file in the project root for more information.
44
// Created by: Alexey Kulakov
@@ -282,9 +282,9 @@ public class IssueJira0537_DropDefaultConstraintBugTest : AutoBuildTest
282282

283283
private ConnectionInfo connectionInfo;
284284

285-
private static string multiDatabaseConnectionString;
286-
private static string singleDatabaseConnectionStringDatabase1;
287-
private static string singleDatabaseConnectionStringDatabase2;
285+
private string multiDatabaseConnectionString;
286+
private string singleDatabaseConnectionStringDatabase1;
287+
private string singleDatabaseConnectionStringDatabase2;
288288

289289
protected override void CheckRequirements()
290290
{
@@ -309,7 +309,7 @@ public void MainTest()
309309
BuildMultipleDomain(Database2Name, Database1Name);
310310
}
311311

312-
private static void BuildMultipleDomain(string coreDatabaseName, string wmsDatabaseName)
312+
private void BuildMultipleDomain(string coreDatabaseName, string wmsDatabaseName)
313313
{
314314
var domainConfiguration = new DomainConfiguration(multiDatabaseConnectionString) {
315315
DefaultDatabase = WmsAlias,
@@ -336,7 +336,7 @@ private static void BuildMultipleDomain(string coreDatabaseName, string wmsDatab
336336
using (var domain = Domain.Build(domainConfiguration)) { }
337337
}
338338

339-
private static void BuildSingleDomain(string wmsDatabaseName)
339+
private void BuildSingleDomain(string wmsDatabaseName)
340340
{
341341
var domainConfiguration = new DomainConfiguration(singleDatabaseConnectionStringDatabase1) {
342342
UpgradeMode = DomainUpgradeMode.Recreate,
@@ -406,8 +406,10 @@ select driver.Compile(SqlDdl.Alter(foreignKeyInfo.Table, SqlDdl.DropConstraint(f
406406

407407
private void InitializeConnectionStrings()
408408
{
409-
410409
connectionInfo = TestConfiguration.Instance.GetConnectionInfo(TestConfiguration.Instance.Storage);
410+
if (connectionInfo == null) {
411+
connectionInfo = DomainConfigurationFactory.Create().ConnectionInfo;
412+
}
411413

412414
var connectionUrl = connectionInfo.ConnectionUrl;
413415

Orm/Xtensive.Orm.Tests/Issues/IssueJira0675_EntityChangeRegistryDoesntClear.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2016-2021 Xtensive LLC.
1+
// Copyright (C) 2016-2025 Xtensive LLC.
22
// This code is distributed under MIT license terms.
33
// See the License.txt file in the project root for more information.
44

@@ -232,11 +232,16 @@ protected override void PopulateData()
232232

233233
private void UpdateEntities(int instanceId)
234234
{
235+
var deadlockDetected = false;
235236
for (var i = 0; i < MaxEntities; i++) {
236237
using (var session = Domain.OpenSession()) {
237-
var retryCount = 3;
238+
var retryCount = 10;
238239
for (var retry = 0; ; retry++) {
239240
var initialValue = 0;
241+
if (deadlockDetected) {
242+
deadlockDetected = false;
243+
Thread.Sleep(30);
244+
}
240245
try {
241246
initialValue = GetEntityValue(session, i);
242247
UpdateEntity(session, i);
@@ -247,6 +252,7 @@ private void UpdateEntities(int instanceId)
247252
ex is TransactionSerializationFailureException ||
248253
(ex is TargetInvocationException && (ex.InnerException is DeadlockException || ex.InnerException is TransactionSerializationFailureException)))
249254
{
255+
deadlockDetected = true;
250256
if (retry + 1 < retryCount) {
251257
Console.WriteLine("Deadlock detected : retrying transactional method for UpdateEntities({0}, {1})", instanceId, i);
252258
var currentValue = GetEntityValue(session, i);
@@ -313,7 +319,7 @@ private int GetEntityValue(Session session, int i)
313319
{
314320
int initialValue;
315321
using (var t = session.OpenTransaction()) {
316-
var entity = Query.All<TestEntity>().Single(e => e.Index == i);
322+
var entity = session.Query.All<TestEntity>().Single(e => e.Index == i);
317323
initialValue = entity.Value;
318324
t.Complete();
319325
}
@@ -323,7 +329,7 @@ private int GetEntityValue(Session session, int i)
323329
private void UpdateEntity(Session session, int i)
324330
{
325331
using (var t = session.OpenTransaction()) {
326-
var entity = Query.All<TestEntity>().Single(e => e.Index == i);
332+
var entity = session.Query.All<TestEntity>().Single(e => e.Index == i);
327333
var initialValue = entity.Value;
328334
entity.Value++;
329335
t.Complete(); // rollback

Orm/Xtensive.Orm.Tests/Issues/IssueJira0720_IncorrectTypeAsChainTranslation.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2019-2024 Xtensive LLC.
1+
// Copyright (C) 2019-2025 Xtensive LLC.
22
// This code is distributed under MIT license terms.
33
// See the License.txt file in the project root for more information.
44
// Created by: Denis Kudelin
@@ -161,6 +161,12 @@ public void Test3()
161161
[Test]
162162
public void Test4()
163163
{
164+
if (StorageProviderInfo.Instance.CheckProviderIs(StorageProvider.MySql)) {
165+
if (StorageProviderInfo.Instance.CheckProviderVersionIsAtLeast(StorageProviderVersion.MySql56)) {
166+
throw new IgnoreException("For some reason exact same queries work in 5.5, broken in 5.6/5.7, and work in 8.0 again");
167+
}
168+
}
169+
164170
using (var session = Domain.OpenSession())
165171
using (var tx = session.OpenTransaction()) {
166172
_ = new TestEntity1(session);

Orm/Xtensive.Orm.Tests/Issues/IssueJira0728_NullGroupHasNoElementsTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ public void GroupByStructureFieldTest4()
307307
}
308308

309309
[Test]
310-
[IgnoreIfGithubActions]
310+
[IgnoreOnGithubActionsIfFailed]
311311
public void GroupBySelectedStructureFieldTest4()
312312
{
313313
Require.AllFeaturesSupported(ProviderFeatures.ScalarSubqueries);

Orm/Xtensive.Orm.Tests/Issues/Issue_0694_SchemaUpgradeBug/UpgradeTest.cs

Lines changed: 49 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,109 +1,98 @@
1-
// Copyright (C) 2003-2010 Xtensive LLC.
2-
// All rights reserved.
3-
// For conditions of distribution and use, see license.
1+
// Copyright (C) 2009-2025 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: Ivan Galkin
55
// Created: 2009.05.20
66

77
using System;
88
using System.Linq;
99
using System.Reflection;
10-
using Xtensive.Core;
11-
using Xtensive.Orm.Tests.Issues.Issue_0694_SchemaUpgradeBug.Model.Version1;
12-
using Xtensive.Orm.Tests.Issues.Issue_0694_SchemaUpgradeBug.Model.Version2;
1310
using M1 = Xtensive.Orm.Tests.Issues.Issue_0694_SchemaUpgradeBug.Model.Version1;
1411
using M2 = Xtensive.Orm.Tests.Issues.Issue_0694_SchemaUpgradeBug.Model.Version2;
1512
using M3 = Xtensive.Orm.Tests.Issues.Issue_0694_SchemaUpgradeBug.Model.Version3;
1613
using NUnit.Framework;
17-
using Content = Xtensive.Orm.Tests.Issues.Issue_0694_SchemaUpgradeBug.Model.Version2.Content;
18-
using Status = Xtensive.Orm.Tests.Issues.Issue_0694_SchemaUpgradeBug.Model.Version1.Status;
14+
15+
1916

2017
namespace Xtensive.Orm.Tests.Issues.Issue_0694_SchemaUpgradeBug
2118
{
2219
[TestFixture]
2320
public class UpgradeTest
2421
{
25-
private Domain domain;
26-
2722
[SetUp]
2823
public void SetUp()
2924
{
30-
BuildDomain("1", DomainUpgradeMode.Recreate);
31-
using (var session = domain.OpenSession()) {
32-
using (var tx = session.OpenTransaction()) {
33-
var status = new Status() {Title = "Status"};
34-
var media = new Media() {Title = "Media", Data = "Data"};
35-
media.Statuses.Add(status);
36-
tx.Complete();
37-
}
25+
using (var domain = BuildDomain("1", DomainUpgradeMode.Recreate))
26+
using (var session = domain.OpenSession())
27+
using (var tx = session.OpenTransaction()) {
28+
var status = new M1.Status() { Title = "Status" };
29+
var media = new M1.Media() { Title = "Media", Data = "Data" };
30+
_ = media.Statuses.Add(status);
31+
tx.Complete();
3832
}
3933
}
4034

4135
[Test]
36+
[IgnoreIfGithubActions(StorageProvider.Firebird)]
4237
public void UpgradeToVersion2Test()
4338
{
44-
BuildDomain("2", DomainUpgradeMode.Perform);
39+
using (var domain = BuildDomain("2", DomainUpgradeMode.Perform))
4540
using (var session = domain.OpenSession())
46-
{
47-
using (session.OpenTransaction())
48-
{
49-
var status = session.Query.All<Model.Version2.Status>().SingleOrDefault();
50-
var newMedia = session.Query.All<NewMedia>().SingleOrDefault();
51-
var newMediaTricky = session.Query.All<Content>().Where(c => c.Title == "Media").SingleOrDefault();
41+
using (session.OpenTransaction()) {
42+
var status = session.Query.All<M2.Status>().SingleOrDefault();
43+
var newMedia = session.Query.All<M2.NewMedia>().SingleOrDefault();
44+
var newMediaTricky = session.Query.All<M2.Content>().Where(c => c.Title == "Media").SingleOrDefault();
5245

53-
int statusCount = session.Query.All<Model.Version2.Status>().Count();
54-
int statusAssociationCount = status != null ? status.AssociatedContent.Count() : 0;
55-
int newMediaCount = session.Query.All<NewMedia>().Count();
46+
var statusCount = session.Query.All<M2.Status>().Count();
47+
var statusAssociationCount = status != null ? status.AssociatedContent.Count() : 0;
48+
var newMediaCount = session.Query.All<M2.NewMedia>().Count();
5649

57-
Assert.IsNotNull(status);
58-
Assert.IsNull(newMedia);
59-
Assert.IsNull(newMediaTricky);
60-
Assert.AreEqual(1, statusCount);
61-
Assert.AreEqual(0, newMediaCount);
62-
Assert.AreEqual(0, statusAssociationCount);
63-
}
50+
Assert.IsNotNull(status);
51+
Assert.IsNull(newMedia);
52+
Assert.IsNull(newMediaTricky);
53+
Assert.AreEqual(1, statusCount);
54+
Assert.AreEqual(0, newMediaCount);
55+
Assert.AreEqual(0, statusAssociationCount);
6456
}
6557
}
66-
58+
6759
[Test, Ignore("Default behavior changed. Namespace-only renames are tracked automatically.")]
6860
public void UpgradeToVersion3Test()
6961
{
70-
BuildDomain("3", DomainUpgradeMode.Perform);
71-
using (var session = domain.OpenSession()) {
72-
using (session.OpenTransaction()) {
73-
// No version-to-version hints, so all the types are removed
74-
var status = session.Query.All<Model.Version3.Status>().FirstOrDefault();
75-
var newMedia = session.Query.All<Model.Version3.NewMedia>().FirstOrDefault();
76-
var newMediaTricky = session.Query.All<Model.Version3.Content>().FirstOrDefault();
62+
using (var domain = BuildDomain("3", DomainUpgradeMode.Perform))
63+
using (var session = domain.OpenSession())
64+
using (session.OpenTransaction()) {
65+
// No version-to-version hints, so all the types are removed
66+
var status = session.Query.All<M3.Status>().FirstOrDefault();
67+
var newMedia = session.Query.All<M3.NewMedia>().FirstOrDefault();
68+
var newMediaTricky = session.Query.All<M3.Content>().FirstOrDefault();
7769

78-
int statusCount = session.Query.All<Model.Version3.Status>().Count();
79-
int statusAssociationCount = status!=null ? status.AssociatedContent.Count() : 0;
80-
int newMediaCount = session.Query.All<Model.Version3.NewMedia>().Count();
70+
var statusCount = session.Query.All<M3.Status>().Count();
71+
var statusAssociationCount = status != null ? status.AssociatedContent.Count() : 0;
72+
var newMediaCount = session.Query.All<M3.NewMedia>().Count();
8173

82-
Assert.IsNull(status);
83-
Assert.IsNull(newMedia);
84-
Assert.IsNull(newMediaTricky);
85-
Assert.AreEqual(0, statusCount);
86-
Assert.AreEqual(0, newMediaCount);
87-
Assert.AreEqual(0, statusAssociationCount);
88-
}
74+
Assert.IsNull(status);
75+
Assert.IsNull(newMedia);
76+
Assert.IsNull(newMediaTricky);
77+
Assert.AreEqual(0, statusCount);
78+
Assert.AreEqual(0, newMediaCount);
79+
Assert.AreEqual(0, statusAssociationCount);
8980
}
9081
}
9182

92-
private void BuildDomain(string version, DomainUpgradeMode upgradeMode)
83+
private Domain BuildDomain(string version, DomainUpgradeMode upgradeMode)
9384
{
94-
if (domain != null)
95-
domain.DisposeSafely();
96-
97-
string ns = typeof(Model.Version1.Content).Namespace;
98-
string nsPrefix = ns.Substring(0, ns.Length - 1);
85+
var ns = typeof(M1.Content).Namespace;
86+
var nsPrefix = ns.Substring(0, ns.Length - 1);
9987

10088
var configuration = DomainConfigurationFactory.Create();
10189
configuration.UpgradeMode = upgradeMode;
90+
configuration.BuildInParallel = false;
10291
configuration.Types.Register(Assembly.GetExecutingAssembly(), nsPrefix + version);
10392
configuration.Types.Register(typeof(Upgrader));
10493

10594
using (Upgrader.Enable(version)) {
106-
domain = Domain.Build(configuration);
95+
return Domain.Build(configuration);
10796
}
10897
}
10998
}

Orm/Xtensive.Orm.Tests/Linq/ComplexTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ private static IQueryable<Customer> GetQuery(QueryEndpoint qe, string filter)
2626
[Test]
2727
public void CachedQueryTest()
2828
{
29-
Assert.Throws<QueryTranslationException>(() => {
29+
_ = Assert.Throws<QueryTranslationException>(() => {
3030
for (char c = 'A'; c <= 'Z'; c++) {
3131
string firstChar = c.ToString();
3232
var builtQuery = GetQuery(Session.Query, firstChar);

0 commit comments

Comments
 (0)