Skip to content

Commit 1545d8a

Browse files
authored
Update NUnit to 3.10.1
- Update test to avoid NUnit regression.
1 parent 4dafb25 commit 1545d8a

File tree

5 files changed

+220
-7
lines changed

5 files changed

+220
-7
lines changed

src/NHibernate.Test.VisualBasic/NHibernate.Test.VisualBasic.vbproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
<PackageReference Include="Microsoft.VisualBasic" Version="10.2.0" />
3333
</ItemGroup>
3434
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.0'">
35-
<PackageReference Include="NUnitLite" Version="3.9.0" />
35+
<PackageReference Include="NUnitLite" Version="3.10.1" />
3636
</ItemGroup>
3737
<ItemGroup>
3838
<ProjectReference Include="..\NHibernate\NHibernate.csproj" />
Lines changed: 113 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,113 @@
1-
//------------------------------------------------------------------------------// <auto-generated>// This code was generated by AsyncGenerator.//// Changes to this file may cause incorrect behavior and will be lost if// the code is regenerated.// </auto-generated>//------------------------------------------------------------------------------using System;using System.Data.Common;using NUnit.Framework;using NHibernate.Dialect;namespace NHibernate.Test.NHSpecificTest.NH2204{ using System.Threading.Tasks; using System.Threading; [TestFixture] public class FixtureAsync : BugTestCase { public override string BugNumber { get { return "NH2204"; } } protected override bool AppliesTo(Dialect.Dialect dialect) { return dialect is PostgreSQL81Dialect; } // create the trigger protected override void OnSetUp() { using (ISession s = OpenSession()) { var command = s.Connection.CreateCommand(); command.CommandText = "CREATE OR REPLACE FUNCTION audit_parent() RETURNS trigger AS $audit_parent$" + Environment.NewLine + "BEGIN" + Environment.NewLine + "INSERT INTO parent_history SELECT nextval('parent_history_histid_seq'), now(), NEW.*;" + Environment.NewLine + "RETURN NEW;" + Environment.NewLine + "END" + Environment.NewLine + " $audit_parent$ LANGUAGE 'plpgsql';"; command.ExecuteNonQuery(); command.CommandText = "CREATE TRIGGER parent_audit" + Environment.NewLine + "AFTER INSERT OR UPDATE ON parent" + Environment.NewLine + "FOR EACH ROW EXECUTE PROCEDURE audit_parent();"; command.ExecuteNonQuery(); } } // remove trigger and remove data from tables protected override void OnTearDown() { using (ISession s = OpenSession()) { var command = s.Connection.CreateCommand(); command.CommandText = "DROP FUNCTION audit_parent() CASCADE;"; command.ExecuteNonQuery(); command.CommandText = "DELETE from parent_history;"; command.ExecuteNonQuery(); command.CommandText = "DELETE from parent;"; command.ExecuteNonQuery(); } } [Test] public void KnownFailure_Correct_Id_Returned_When_Using_TriggerAsync() { Assert.ThrowsAsync<AssertionException>(() => RunTestAsync(), "We expected this test to fail - if the problem has been fixed, clean-up the test."); } private async Task RunTestAsync(CancellationToken cancellationToken = default(CancellationToken)) { var entity1 = new Parent {Name = "Parent1_0"}; // when saved this entity should have the id of 1 var entity2 = new Parent {Name = "Parent2_0"}; // when saved this entity should have the id of 2 var entity3 = new Parent {Name = "Parent3_0"}; // when saved this entity should have the id of 3 using (ISession s = OpenSession()) { // save first entity await (s.SaveAsync(entity1, cancellationToken)); await (s.FlushAsync(cancellationToken)); Assert.AreEqual(1, entity1.Id); // save second entity await (s.SaveAsync(entity2, cancellationToken)); await (s.FlushAsync(cancellationToken)); Assert.AreEqual(2, entity2.Id); // update this entity 10 times - adds entries to the audit table // causing the sequences for the parent and history table to no longer be aligned for (int i = 1; i < 11; i++) { entity2.Name = string.Format("Parent2_{0}", i); await (s.UpdateAsync(entity2, cancellationToken)); await (s.FlushAsync(cancellationToken)); } // save third entity await (s.SaveAsync(entity3, cancellationToken)); await (s.FlushAsync(cancellationToken)); Assert.AreEqual( 3, entity3.Id, "oh uh - it would appear that lastval() is not our friend when a trigger updates other sequences."); // now would be a good time to look at the data in the tables and see that they have the IDs as expected // which are not the same as those returned by nhibernate } } }}
1+
//------------------------------------------------------------------------------
2+
// <auto-generated>
3+
// This code was generated by AsyncGenerator.
4+
//
5+
// Changes to this file may cause incorrect behavior and will be lost if
6+
// the code is regenerated.
7+
// </auto-generated>
8+
//------------------------------------------------------------------------------
9+
10+
11+
using System;
12+
using System.Data.Common;
13+
using NUnit.Framework;
14+
using NHibernate.Dialect;
15+
16+
17+
namespace NHibernate.Test.NHSpecificTest.NH2204
18+
{
19+
using System.Threading.Tasks;
20+
[TestFixture]
21+
public class FixtureAsync : BugTestCase
22+
{
23+
protected override bool AppliesTo(Dialect.Dialect dialect)
24+
{
25+
return dialect is PostgreSQL81Dialect;
26+
}
27+
28+
// create the trigger
29+
protected override void OnSetUp()
30+
{
31+
using (var s = OpenSession())
32+
{
33+
var command = s.Connection.CreateCommand();
34+
35+
command.CommandText = "CREATE OR REPLACE FUNCTION audit_parent() RETURNS trigger AS $audit_parent$" +
36+
Environment.NewLine +
37+
"BEGIN" + Environment.NewLine +
38+
"INSERT INTO parent_history SELECT nextval('parent_history_histid_seq'), now(), NEW.*;" +
39+
Environment.NewLine +
40+
"RETURN NEW;" + Environment.NewLine +
41+
"END" + Environment.NewLine +
42+
" $audit_parent$ LANGUAGE 'plpgsql';";
43+
command.ExecuteNonQuery();
44+
45+
command.CommandText = "CREATE TRIGGER parent_audit" + Environment.NewLine +
46+
"AFTER INSERT OR UPDATE ON parent" + Environment.NewLine +
47+
"FOR EACH ROW EXECUTE PROCEDURE audit_parent();";
48+
command.ExecuteNonQuery();
49+
}
50+
}
51+
52+
// remove trigger and remove data from tables
53+
protected override void OnTearDown()
54+
{
55+
using (var s = OpenSession())
56+
{
57+
var command = s.Connection.CreateCommand();
58+
command.CommandText = "DROP FUNCTION audit_parent() CASCADE;";
59+
command.ExecuteNonQuery();
60+
command.CommandText = "DELETE from parent_history;";
61+
command.ExecuteNonQuery();
62+
command.CommandText = "DELETE from parent;";
63+
command.ExecuteNonQuery();
64+
}
65+
}
66+
67+
68+
[Test]
69+
public async Task KnownFailure_Correct_Id_Returned_When_Using_TriggerAsync()
70+
{
71+
//We expected this test to fail - if the problem has been fixed, clean-up the test.
72+
var entity1 = new Parent {Name = "Parent1_0"}; // when saved this entity should have the id of 1
73+
var entity2 = new Parent {Name = "Parent2_0"}; // when saved this entity should have the id of 2
74+
var entity3 = new Parent {Name = "Parent3_0"}; // when saved this entity should have the id of 3
75+
76+
using (var s = OpenSession())
77+
{
78+
// save first entity
79+
await (s.SaveAsync(entity1));
80+
await (s.FlushAsync());
81+
82+
Assert.That(entity1.Id, Is.EqualTo(1));
83+
84+
// save second entity
85+
await (s.SaveAsync(entity2));
86+
await (s.FlushAsync());
87+
88+
Assert.That(entity2.Id, Is.EqualTo(2));
89+
90+
// update this entity 10 times - adds entries to the audit table
91+
// causing the sequences for the parent and history table to no longer be aligned
92+
for (var i = 1; i < 11; i++)
93+
{
94+
entity2.Name = string.Format("Parent2_{0}", i);
95+
await (s.UpdateAsync(entity2));
96+
await (s.FlushAsync());
97+
}
98+
99+
// save third entity
100+
await (s.SaveAsync(entity3));
101+
await (s.FlushAsync());
102+
103+
Warn.Unless(
104+
entity3.Id,
105+
Is.EqualTo(3),
106+
"oh uh - it would appear that lastval() is not our friend when a trigger updates other sequences.");
107+
108+
// now would be a good time to look at the data in the tables and see that they have the IDs as expected
109+
// which are not the same as those returned by nhibernate
110+
}
111+
}
112+
}
113+
}
Lines changed: 102 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,102 @@
1-
using System;using System.Data.Common;using NUnit.Framework;using NHibernate.Dialect;namespace NHibernate.Test.NHSpecificTest.NH2204{ [TestFixture] public class Fixture : BugTestCase { public override string BugNumber { get { return "NH2204"; } } protected override bool AppliesTo(Dialect.Dialect dialect) { return dialect is PostgreSQL81Dialect; } // create the trigger protected override void OnSetUp() { using (ISession s = OpenSession()) { var command = s.Connection.CreateCommand(); command.CommandText = "CREATE OR REPLACE FUNCTION audit_parent() RETURNS trigger AS $audit_parent$" + Environment.NewLine + "BEGIN" + Environment.NewLine + "INSERT INTO parent_history SELECT nextval('parent_history_histid_seq'), now(), NEW.*;" + Environment.NewLine + "RETURN NEW;" + Environment.NewLine + "END" + Environment.NewLine + " $audit_parent$ LANGUAGE 'plpgsql';"; command.ExecuteNonQuery(); command.CommandText = "CREATE TRIGGER parent_audit" + Environment.NewLine + "AFTER INSERT OR UPDATE ON parent" + Environment.NewLine + "FOR EACH ROW EXECUTE PROCEDURE audit_parent();"; command.ExecuteNonQuery(); } } // remove trigger and remove data from tables protected override void OnTearDown() { using (ISession s = OpenSession()) { var command = s.Connection.CreateCommand(); command.CommandText = "DROP FUNCTION audit_parent() CASCADE;"; command.ExecuteNonQuery(); command.CommandText = "DELETE from parent_history;"; command.ExecuteNonQuery(); command.CommandText = "DELETE from parent;"; command.ExecuteNonQuery(); } } [Test] public void KnownFailure_Correct_Id_Returned_When_Using_Trigger() { Assert.Throws<AssertionException>(() => RunTest(), "We expected this test to fail - if the problem has been fixed, clean-up the test."); } private void RunTest() { var entity1 = new Parent {Name = "Parent1_0"}; // when saved this entity should have the id of 1 var entity2 = new Parent {Name = "Parent2_0"}; // when saved this entity should have the id of 2 var entity3 = new Parent {Name = "Parent3_0"}; // when saved this entity should have the id of 3 using (ISession s = OpenSession()) { // save first entity s.Save(entity1); s.Flush(); Assert.AreEqual(1, entity1.Id); // save second entity s.Save(entity2); s.Flush(); Assert.AreEqual(2, entity2.Id); // update this entity 10 times - adds entries to the audit table // causing the sequences for the parent and history table to no longer be aligned for (int i = 1; i < 11; i++) { entity2.Name = string.Format("Parent2_{0}", i); s.Update(entity2); s.Flush(); } // save third entity s.Save(entity3); s.Flush(); Assert.AreEqual( 3, entity3.Id, "oh uh - it would appear that lastval() is not our friend when a trigger updates other sequences."); // now would be a good time to look at the data in the tables and see that they have the IDs as expected // which are not the same as those returned by nhibernate } } }}
1+
using System;
2+
using System.Data.Common;
3+
using NUnit.Framework;
4+
using NHibernate.Dialect;
5+
6+
7+
namespace NHibernate.Test.NHSpecificTest.NH2204
8+
{
9+
[TestFixture]
10+
public class Fixture : BugTestCase
11+
{
12+
protected override bool AppliesTo(Dialect.Dialect dialect)
13+
{
14+
return dialect is PostgreSQL81Dialect;
15+
}
16+
17+
// create the trigger
18+
protected override void OnSetUp()
19+
{
20+
using (var s = OpenSession())
21+
{
22+
var command = s.Connection.CreateCommand();
23+
24+
command.CommandText = "CREATE OR REPLACE FUNCTION audit_parent() RETURNS trigger AS $audit_parent$" +
25+
Environment.NewLine +
26+
"BEGIN" + Environment.NewLine +
27+
"INSERT INTO parent_history SELECT nextval('parent_history_histid_seq'), now(), NEW.*;" +
28+
Environment.NewLine +
29+
"RETURN NEW;" + Environment.NewLine +
30+
"END" + Environment.NewLine +
31+
" $audit_parent$ LANGUAGE 'plpgsql';";
32+
command.ExecuteNonQuery();
33+
34+
command.CommandText = "CREATE TRIGGER parent_audit" + Environment.NewLine +
35+
"AFTER INSERT OR UPDATE ON parent" + Environment.NewLine +
36+
"FOR EACH ROW EXECUTE PROCEDURE audit_parent();";
37+
command.ExecuteNonQuery();
38+
}
39+
}
40+
41+
// remove trigger and remove data from tables
42+
protected override void OnTearDown()
43+
{
44+
using (var s = OpenSession())
45+
{
46+
var command = s.Connection.CreateCommand();
47+
command.CommandText = "DROP FUNCTION audit_parent() CASCADE;";
48+
command.ExecuteNonQuery();
49+
command.CommandText = "DELETE from parent_history;";
50+
command.ExecuteNonQuery();
51+
command.CommandText = "DELETE from parent;";
52+
command.ExecuteNonQuery();
53+
}
54+
}
55+
56+
57+
[Test]
58+
public void KnownFailure_Correct_Id_Returned_When_Using_Trigger()
59+
{
60+
//We expected this test to fail - if the problem has been fixed, clean-up the test.
61+
var entity1 = new Parent {Name = "Parent1_0"}; // when saved this entity should have the id of 1
62+
var entity2 = new Parent {Name = "Parent2_0"}; // when saved this entity should have the id of 2
63+
var entity3 = new Parent {Name = "Parent3_0"}; // when saved this entity should have the id of 3
64+
65+
using (var s = OpenSession())
66+
{
67+
// save first entity
68+
s.Save(entity1);
69+
s.Flush();
70+
71+
Assert.That(entity1.Id, Is.EqualTo(1));
72+
73+
// save second entity
74+
s.Save(entity2);
75+
s.Flush();
76+
77+
Assert.That(entity2.Id, Is.EqualTo(2));
78+
79+
// update this entity 10 times - adds entries to the audit table
80+
// causing the sequences for the parent and history table to no longer be aligned
81+
for (var i = 1; i < 11; i++)
82+
{
83+
entity2.Name = string.Format("Parent2_{0}", i);
84+
s.Update(entity2);
85+
s.Flush();
86+
}
87+
88+
// save third entity
89+
s.Save(entity3);
90+
s.Flush();
91+
92+
Warn.Unless(
93+
entity3.Id,
94+
Is.EqualTo(3),
95+
"oh uh - it would appear that lastval() is not our friend when a trigger updates other sequences.");
96+
97+
// now would be a good time to look at the data in the tables and see that they have the IDs as expected
98+
// which are not the same as those returned by nhibernate
99+
}
100+
}
101+
}
102+
}

src/NHibernate.Test/NHibernate.Test.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@
5050
<PackageReference Include="log4net" Version="2.0.8" />
5151
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.0.8" />
5252
<PackageReference Include="NSubstitute" Version="3.0.1" />
53-
<PackageReference Include="NUnit" Version="3.9.0" />
54-
<PackageReference Include="NUnit3TestAdapter" Version="3.9.0" />
53+
<PackageReference Include="NUnit" Version="3.10.1" />
54+
<PackageReference Include="NUnit3TestAdapter" Version="3.10.0" />
5555
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
5656
<PackageReference Include="FirebirdSql.Data.FirebirdClient" Version="5.12.1" />
5757
<PackageReference Include="Npgsql" Version="3.2.4.1" />
@@ -72,7 +72,7 @@
7272
<PackageReference Include="System.Data.OracleClient" Version="1.0.8" />
7373
<PackageReference Include="System.Data.Odbc" Version="4.5.0-preview1-25914-04" />
7474
<PackageReference Include="System.Net.NameResolution" Version="4.3.0" />
75-
<PackageReference Include="NUnitLite" Version="3.9.0" />
75+
<PackageReference Include="NUnitLite" Version="3.10.1" />
7676
<PackageReference Include="MySql.Data" Version="6.10.6" />
7777
</ItemGroup>
7878
<ItemGroup Condition=" '$(NuGetPackageRoot)' != '' ">

src/NHibernate.TestDatabaseSetup/NHibernate.TestDatabaseSetup.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<ProjectReference Include="..\NHibernate.Test\NHibernate.Test.csproj" />
1919
</ItemGroup>
2020
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.0'">
21-
<PackageReference Include="NUnitLite" Version="3.9.0" />
21+
<PackageReference Include="NUnitLite" Version="3.10.1" />
2222
</ItemGroup>
2323
<ItemGroup>
2424
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />

0 commit comments

Comments
 (0)