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 Tools/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
<package id="NUnit.Extension.NUnitV2ResultWriter" version="3.6.0" targetFramework="net461" />
<package id="NUnit.Extension.TeamCityEventListener" version="1.0.2" targetFramework="net461" />
<package id="NUnit.Extension.VSProjectLoader" version="3.6.0" targetFramework="net461" />
<package id="CSharpAsyncGenerator.CommandLine" version="0.6.0" targetFramework="net461" />
<package id="CSharpAsyncGenerator.CommandLine" version="0.8.2.4" targetFramework="net461" />
<package id="vswhere" version="2.1.4" targetFramework="net461" />
</packages>
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ public async Task MergeEntityWithNonNullableEntityNullAsync()
await (session.MergeAsync(route, cancellationToken));
Assert.Fail("should have thrown an exception");
}
catch (OperationCanceledException) { throw; }
catch (Exception ex)
{
Assert.That(ex, Is.TypeOf(typeof(PropertyValueException)));
Expand Down
1 change: 1 addition & 0 deletions src/NHibernate.Test/Async/DebugConnectionProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public override async Task<DbConnection> GetConnectionAsync(CancellationToken ca
connections.TryAdd(connection, 0);
return connection;
}
catch (OperationCanceledException) { throw; }
catch (Exception e)
{
throw new HibernateException("Could not open connection to: " + ConnectionString, e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ public override Task UpdateParentOneToTwoSameChildrenAsync()
{
Assert.Ignore("Not supported");
return Task.CompletedTask;
// This test need some more deep study if it really work in H3.2
// because <bag> allow duplication.
}
catch (System.Exception ex)
{
return Task.FromException<object>(ex);
}
// This test need some more deep study if it really work in H3.2
// because <bag> allow duplication.
}
}
}
35 changes: 0 additions & 35 deletions src/NHibernate.Test/Async/ExpressionTest/QueryByExampleTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
namespace NHibernate.Test.ExpressionTest
{
using System.Threading.Tasks;
using System.Threading;
[TestFixture]
public class QueryByExampleTestAsync : TestCase
{
Expand Down Expand Up @@ -150,30 +149,6 @@ public async Task TestExcludingQBEAsync()
}
}

private async Task InitDataAsync(CancellationToken cancellationToken = default(CancellationToken))
{
using (ISession s = OpenSession())
{
Componentizable master = GetMaster("hibernate", "ORM tool", "ORM tool1");
await (s.SaveAsync(master, cancellationToken));
await (s.FlushAsync(cancellationToken));
}

using (ISession s = OpenSession())
{
Componentizable master = GetMaster("hibernate", "open source", "open source1");
await (s.SaveAsync(master, cancellationToken));
await (s.FlushAsync(cancellationToken));
}

using (ISession s = OpenSession())
{
Componentizable master = GetMaster("hibernate", null, null);
await (s.SaveAsync(master, cancellationToken));
await (s.FlushAsync(cancellationToken));
}
}

private void InitData()
{
using (ISession s = OpenSession())
Expand All @@ -198,16 +173,6 @@ private void InitData()
}
}

private async Task DeleteDataAsync(CancellationToken cancellationToken = default(CancellationToken))
{
using (ISession s = OpenSession())
using (ITransaction t = s.BeginTransaction())
{
await (s.DeleteAsync("from Componentizable", cancellationToken));
await (t.CommitAsync(cancellationToken));
}
}

private void DeleteData()
{
using (ISession s = OpenSession())
Expand Down
3 changes: 2 additions & 1 deletion src/NHibernate.Test/Async/NHSpecificTest/Logs/LogsFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ public async Task WillGetSessionIdFromSessionLogsConcurrentAsync()
var sessionIds = new ConcurrentDictionary<int, Guid>();
using (var spy = new TextLogSpy("NHibernate.SQL", "%message | SessionId: %property{sessionId}"))
{
await (Task.WhenAll(Enumerable.Range( 1, 12).Select( async i =>
await (Task.WhenAll(
Enumerable.Range(1, 12 - 1).Select(async i =>
{
if (i > 10)
{
Expand Down
66 changes: 0 additions & 66 deletions src/NHibernate.Test/Async/NHSpecificTest/NH1507/Fixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
namespace NHibernate.Test.NHSpecificTest.NH1507
{
using System.Threading.Tasks;
using System.Threading;
[TestFixture]
public class FixtureAsync : BugTestCase
{
Expand All @@ -35,54 +34,6 @@ protected override void OnTearDown()
CleanupData();
}

private async Task CreateDataAsync(CancellationToken cancellationToken = default(CancellationToken))
{
//Employee
var emp = new Employee
{
Address = "Zombie street",
City = "Bitonto",
PostalCode = "66666",
FirstName = "tomb",
LastName = "mutilated"
};

//and his related orders
var order = new Order
{OrderDate = DateTime.Now, Employee = emp, ShipAddress = "dead zone 1", ShipCountry = "Deadville"};

var order2 = new Order
{OrderDate = DateTime.Now, Employee = emp, ShipAddress = "dead zone 2", ShipCountry = "Deadville"};

//Employee with no related orders but with same PostalCode
var emp2 = new Employee
{
Address = "Gut street",
City = "Mariotto",
Country = "Arised",
PostalCode = "66666",
FirstName = "carcass",
LastName = "purulent"
};

//Order with no related employee but with same ShipCountry
var order3 = new Order {OrderDate = DateTime.Now, ShipAddress = "dead zone 2", ShipCountry = "Deadville"};

using (ISession session = OpenSession())
{
using (ITransaction tx = session.BeginTransaction())
{
await (session.SaveAsync(emp, cancellationToken));
await (session.SaveAsync(emp2, cancellationToken));
await (session.SaveAsync(order, cancellationToken));
await (session.SaveAsync(order2, cancellationToken));
await (session.SaveAsync(order3, cancellationToken));

await (tx.CommitAsync(cancellationToken));
}
}
}

private void CreateData()
{
//Employee
Expand Down Expand Up @@ -131,23 +82,6 @@ private void CreateData()
}
}

private async Task CleanupDataAsync(CancellationToken cancellationToken = default(CancellationToken))
{
using (ISession session = OpenSession())
{
using (ITransaction tx = session.BeginTransaction())
{
//delete empolyee and related orders
await (session.DeleteAsync("from Employee ee where ee.PostalCode = '66666'", cancellationToken));

//delete order not related to employee
await (session.DeleteAsync("from Order oo where oo.ShipCountry = 'Deadville'", cancellationToken));

await (tx.CommitAsync(cancellationToken));
}
}
}

private void CleanupData()
{
using (ISession session = OpenSession())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,17 +159,6 @@ protected override bool AppliesTo(ISessionFactoryImplementor factory)
return factory.ConnectionProvider.Driver is SqlClientDriver;
}

private async Task SetAllowSnapshotIsolationAsync(bool on, CancellationToken cancellationToken = default(CancellationToken))
{
using (ISession session = OpenSession())
{
var command = session.Connection.CreateCommand();
command.CommandText = "ALTER DATABASE " + session.Connection.Database + " set allow_snapshot_isolation "
+ (on ? "on" : "off");
await (command.ExecuteNonQueryAsync(cancellationToken));
}
}

private void SetAllowSnapshotIsolation(bool on)
{
using (ISession session = OpenSession())
Expand Down
17 changes: 0 additions & 17 deletions src/NHibernate.Test/Async/NHSpecificTest/NH1792/Fixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
namespace NHibernate.Test.NHSpecificTest.NH1792
{
using System.Threading.Tasks;
using System.Threading;
[TestFixture]
public class FixtureAsync : BugTestCase
{
Expand All @@ -25,22 +24,6 @@ protected override void OnTearDown()
DeleteAll();
}

/// <summary>
/// Deletes all the product entities from the persistence medium
/// </summary>
/// <param name="cancellationToken">A cancellation token that can be used to cancel the work</param>
private async Task DeleteAllAsync(CancellationToken cancellationToken = default(CancellationToken))
{
using (ISession session = OpenSession())
{
using (ITransaction trans = session.BeginTransaction())
{
await (session.DeleteAsync("from Product", cancellationToken));
await (trans.CommitAsync(cancellationToken));
}
}
}

/// <summary>
/// Deletes all the product entities from the persistence medium
/// </summary>
Expand Down
11 changes: 0 additions & 11 deletions src/NHibernate.Test/Async/NHSpecificTest/NH2302/Fixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
namespace NHibernate.Test.NHSpecificTest.NH2302
{
using System.Threading.Tasks;
using System.Threading;
[TestFixture]
public class FixtureAsync : BugTestCase
{
Expand Down Expand Up @@ -197,16 +196,6 @@ public async Task BlobWithoutLengthAsync()
}
}

private async Task CleanUpAsync(CancellationToken cancellationToken = default(CancellationToken))
{
using (ISession session = OpenSession())
using (ITransaction tx = session.BeginTransaction())
{
await (session.DeleteAsync("from StringLengthEntity", cancellationToken));
await (tx.CommitAsync(cancellationToken));
}
}

private void CleanUp()
{
using (ISession session = OpenSession())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,18 +305,6 @@ protected override void OnTearDown()
}
}

private static Task DeleteAllAsync<T>(ISession session, CancellationToken cancellationToken = default(CancellationToken))
{
try
{
return session.CreateQuery("delete from " + typeof(T).Name).ExecuteUpdateAsync(cancellationToken);
}
catch (Exception ex)
{
return Task.FromException<object>(ex);
}
}

private static void DeleteAll<T>(ISession session)
{
session.CreateQuery("delete from " + typeof(T).Name).ExecuteUpdate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,34 +273,6 @@ private static TransactionScope CreateDistributedTransactionScope()
return scope;
}

private async Task RunScriptAsync(string script, CancellationToken cancellationToken = default(CancellationToken))
{
var cxnString = cfg.Properties["connection.connection_string"] + "; Pooling=No";
// Disable connection pooling so this won't be hindered by
// problems encountered during the actual test

string sql;
using (var reader = new StreamReader(GetType().Assembly.GetManifestResourceStream(GetType().Namespace + "." + script)))
{
sql = await (reader.ReadToEndAsync());
}

using (var cxn = new SqlConnection(cxnString))
{
await (cxn.OpenAsync(cancellationToken));

foreach (var batch in Regex.Split(sql, @"^go\s*$", RegexOptions.IgnoreCase | RegexOptions.Multiline)
.Where(b => !string.IsNullOrEmpty(b)))
{

using (var cmd = new System.Data.SqlClient.SqlCommand(batch, cxn))
{
await (cmd.ExecuteNonQueryAsync(cancellationToken));
}
}
}
}

private void RunScript(string script)
{
var cxnString = cfg.Properties["connection.connection_string"] + "; Pooling=No";
Expand Down
Loading