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 .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools":{
"csharpasyncgenerator.tool": {
"version": "0.21.1",
"version": "0.22.0",
"commands": [
"async-generator"
]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/GenerateAsyncCode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
dotnet-version: 8.0.x

- name: Generate Async code
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
dotnet-version: 8.0.x

- name: Compile and run tests
run: dotnet test Src\\Envers.sln -c Release -f net6.0
run: dotnet test Src\\Envers.sln -c Release -f net8.0
4 changes: 2 additions & 2 deletions Src/AsyncGenerator.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
projects:
- filePath: NHibernate.Envers/NHibernate.Envers.csproj
targetFramework: netcoreapp2.0
targetFramework: net8.0
concurrentRun: true
applyChanges: true
analyzation:
Expand Down Expand Up @@ -41,7 +41,7 @@ projects:
- type: AsyncGenerator.Core.Plugins.EmptyRegionRemover
assemblyName: AsyncGenerator.Core
- filePath: NHibernate.Envers.Tests/NHibernate.Envers.Tests.csproj
targetFramework: net6.0
targetFramework: net8.0
concurrentRun: true
applyChanges: true
analyzation:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,17 @@ public async Task ShouldAuditAsync()
(await (AuditReader().GetRevisionsAsync(typeof(AuditedTestEntity),1)).ConfigureAwait(false))
.Should().Have.SameSequenceAs(1, 2);
}

[Test]
public void ShouldNotAuditAsync()
{
AuditReader().IsEntityClassAudited(typeof(NotAuditedTestEntity))
.Should().Be.False();
AuditReader().IsEntityNameAudited(typeof(NotAuditedTestEntity).FullName)
.Should().Be.False();

Assert.ThrowsAsync<NotAuditedException>(() =>
AuditReader().GetRevisionsAsync(typeof(NotAuditedTestEntity), 1));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//------------------------------------------------------------------------------
// <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 NHibernate.Envers.Exceptions;
using NUnit.Framework;

namespace NHibernate.Envers.Tests.Integration.Basic
{
using System.Threading.Tasks;
public partial class NonVersionedTest : TestBase
{

[Test]
public void VerifyRevisionCountAsync()
{
Assert.ThrowsAsync<NotAuditedException>(() =>
AuditReader().GetRevisionsAsync(typeof(BasicTestEntity3),id1)
);
}

[Test]
public void VerifyHistoryAsync()
{
Assert.ThrowsAsync<NotAuditedException>(() =>
AuditReader().FindAsync<BasicTestEntity3>(id1, 1)
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ namespace NHibernate.Envers.Tests.Integration.Basic
public partial class OutsideTransactionTest : TestBase
{

[Test]
public void ShouldThrowIfInsertOutsideActiveTransactionAsync()
{
// Illegal insertion of entity outside of active transaction.
var entity = new StrTestEntity {Str = "data"};
Assert.ThrowsAsync<AuditException>(async () =>
{
await (Session.SaveAsync(entity)).ConfigureAwait(false);
await (Session.FlushAsync()).ConfigureAwait(false);
});
}

[Test]
public async Task ShouldThrowIfUpdateOutsideActiveTransactionAsync()
{
Expand All @@ -33,9 +45,9 @@ public async Task ShouldThrowIfUpdateOutsideActiveTransactionAsync()
}
// Illegal modification of entity state outside of active transaction.
entity.Str = "modified data";
Assert.Throws<AuditException>(() => {
Session.Update(entity);
Session.Flush();
Assert.ThrowsAsync<AuditException>(async () => {
await (Session.UpdateAsync(entity)).ConfigureAwait(false);
await (Session.FlushAsync()).ConfigureAwait(false);
});
}

Expand All @@ -49,10 +61,10 @@ public async Task ShouldThrowIfDeleteOutsideActiveTransactionAsync()
await (tx.CommitAsync()).ConfigureAwait(false);
}
// Illegal modification of entity state outside of active transaction.
Assert.Throws<AuditException>(() =>
Assert.ThrowsAsync<AuditException>(async () =>
{
Session.Delete(entity);
Session.Flush();
await (Session.DeleteAsync(entity)).ConfigureAwait(false);
await (Session.FlushAsync()).ConfigureAwait(false);
});
}

Expand All @@ -69,10 +81,10 @@ public async Task ShouldThrowIfCollectionUpdateOutsideActiveTransactionAsync()
}
// Illegal collection update outside of active transaction.
person.Names.Remove(name);
Assert.Throws<AuditException>(() =>
Assert.ThrowsAsync<AuditException>(async () =>
{
Session.Update(person);
Session.Flush();
await (Session.UpdateAsync(person)).ConfigureAwait(false);
await (Session.FlushAsync()).ConfigureAwait(false);
});
}

Expand All @@ -89,10 +101,10 @@ public async Task ShouldThrowIfCollectionRemovalOutsideActiveTransactionAsync()
}
// Illegal collection update outside of active transaction.
person.Names = null;
Assert.Throws<AuditException>(() =>
Assert.ThrowsAsync<AuditException>(async () =>
{
Session.Update(person);
Session.Flush();
await (Session.UpdateAsync(person)).ConfigureAwait(false);
await (Session.FlushAsync()).ConfigureAwait(false);
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public async Task VerifyRetrieveNonAuditedAsync()

si.Data.Should().Be.EqualTo(nai.Data);

Assert.Throws<NotAuditedException>(() =>
AuditReader().Find<NonAuditedImplementor>(naiId, 1));
Assert.ThrowsAsync<NotAuditedException>(() =>
AuditReader().FindAsync<NonAuditedImplementor>(naiId, 1));

(await (AuditReader().FindAsync<ISimple>(naiId, 1)).ConfigureAwait(false))
.Should().Be.Null();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public async Task VerifyRetrieveNonAuditedAsync()

si.Data.Should().Be.EqualTo(nai.Data);

Assert.Throws<NotAuditedException>(() =>
AuditReader().Find<NonAuditedImplementor>(naiId, 1));
Assert.ThrowsAsync<NotAuditedException>(() =>
AuditReader().FindAsync<NonAuditedImplementor>(naiId, 1));

(await (AuditReader().FindAsync<ISimple>(naiId, 1)).ConfigureAwait(false))
.Should().Be.Null();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public async Task VerifyRetrieveNonAuditedAsync()

si.Data.Should().Be.EqualTo(nai.Data);

Assert.Throws<NotAuditedException>(() =>
AuditReader().Find<NonAuditedImplementor>(naiId, 1));
Assert.ThrowsAsync<NotAuditedException>(() =>
AuditReader().FindAsync<NonAuditedImplementor>(naiId, 1));

(await (AuditReader().FindAsync<ISimple>(naiId, 1)).ConfigureAwait(false))
.Should().Be.Null();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ public async Task VerifyRevisionsCountsForAuditedAsync()
.Should().Have.SameSequenceAs(1, 2);
}

[Test]
public void VerifyRevisionsCountsForNotAuditedAsync()
{
Assert.ThrowsAsync<NotAuditedException>(() =>
AuditReader().GetRevisionsAsync(typeof (NotAuditedSubclassEntity), id2_1));
}

[Test]
public async Task VerifyHistoryOfAuditedAsync()
{
Expand All @@ -42,5 +49,12 @@ public async Task VerifyHistoryOfAuditedAsync()
rev1.Should().Be.EqualTo(ver1);
rev2.Should().Be.EqualTo(ver2);
}

[Test]
public void VerifyHistoryOfNotAuditedAsync()
{
Assert.ThrowsAsync<NotAuditedException>(() =>
AuditReader().FindAsync(typeof(NotAuditedSubclassEntity), id2_1, 1));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ public async Task VerifyRevisionsCountsForAuditedAsync()
.Should().Have.SameSequenceAs(1, 2);
}

[Test]
public void VerifyRevisionsCountsForNotAuditedAsync()
{
Assert.ThrowsAsync<NotAuditedException>(() =>
AuditReader().GetRevisionsAsync(typeof(NotAuditedSubclassEntity), id2_1));
}

[Test]
public async Task VerifyHistoryOfAuditedAsync()
{
Expand All @@ -42,5 +49,12 @@ public async Task VerifyHistoryOfAuditedAsync()
rev1.Should().Be.EqualTo(ver1);
rev2.Should().Be.EqualTo(ver2);
}

[Test]
public void VerifyHistoryOfNotAuditedAsync()
{
Assert.ThrowsAsync<NotAuditedException>(() =>
AuditReader().FindAsync(typeof(NotAuditedSubclassEntity), id2_1, 1));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ public async Task VerifyRevisionsCountsForAuditedAsync()
.Should().Have.SameSequenceAs(1, 2);
}

[Test]
public void VerifyRevisionsCountsForNotAuditedAsync()
{
Assert.ThrowsAsync<NotAuditedException>(() =>
AuditReader().GetRevisionsAsync(typeof(NotAuditedSubclassEntity), id2_1));
}

[Test]
public async Task VerifyHistoryOfAuditedAsync()
{
Expand All @@ -41,5 +48,12 @@ public async Task VerifyHistoryOfAuditedAsync()
rev1.Should().Be.EqualTo(ver1);
rev2.Should().Be.EqualTo(ver2);
}

[Test]
public void VerifyHistoryOfNotAuditedAsync()
{
Assert.ThrowsAsync<NotAuditedException>(() =>
AuditReader().FindAsync(typeof(NotAuditedSubclassEntity), id2_1, 1));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ public async Task VerifyRevisionsCountsForAuditedAsync()
.Should().Have.SameSequenceAs(1, 2);
}

[Test]
public void VerifyRevisionsCountsForNotAuditedAsync()
{
Assert.ThrowsAsync<NotAuditedException>(() =>
AuditReader().GetRevisionsAsync(typeof(NotAuditedSubclassEntity), id2_1));
}

[Test]
public async Task VerifyHistoryOfAuditedAsync()
{
Expand All @@ -41,5 +48,12 @@ public async Task VerifyHistoryOfAuditedAsync()
rev1.Should().Be.EqualTo(ver1);
rev2.Should().Be.EqualTo(ver2);
}

[Test]
public void VerifyHistoryOfNotAuditedAsync()
{
Assert.ThrowsAsync<NotAuditedException>(() =>
AuditReader().FindAsync(typeof(NotAuditedSubclassEntity), id2_1, 1));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <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.Collections.Generic;
using NHibernate.Envers.Exceptions;
using NUnit.Framework;

namespace NHibernate.Envers.Tests.NetSpecific.Integration.Query
{
using System.Threading.Tasks;
public partial class QueryForNonAuditEntityTest : TestBase
{

[Test]
public void ShouldThrowWhenFindAsync()
{
Assert.ThrowsAsync<NotAuditedException>(() =>
AuditReader().FindAsync<QueryForNonAuditEntityTest>(1, 1)
);
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,14 @@ public async Task ShouldBeAbleToUseInOnSingleSideAsync()
.Add(AuditEntity.Property("Data").Eq("bar"))
.ResultsAsync()).ConfigureAwait(false)).Should().Contain(ing);
}

[Test]
public void ShouldThrowUsingInOnCollectionAsync()
{
Assert.ThrowsAsync<AuditException>(() =>
AuditReader().CreateQuery().ForRevisionsOf<SetRefEdEntity>()
.Add(AuditEntity.Property("Reffering").In(new List<SetRefIngEntity> {ing}))
.ResultsAsync());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace NHibernate.Envers.Tests.Integration.Basic
{
public class NonVersionedTest : TestBase
public partial class NonVersionedTest : TestBase
{
private int id1;

Expand Down
Loading
Loading