|
|
|
@ -6,6 +6,7 @@ using NSubstitute; |
|
|
|
using Shouldly; |
|
|
|
using Volo.Abp.Domain.Entities.Events; |
|
|
|
using Volo.Abp.TestApp; |
|
|
|
using Volo.Abp.TestApp.Domain; |
|
|
|
using Volo.Abp.TestApp.Testing; |
|
|
|
using Xunit; |
|
|
|
|
|
|
|
@ -85,6 +86,33 @@ public class Auditing_Tests : Auditing_Tests<AbpEntityFrameworkCoreTestModule> |
|
|
|
})); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task Should_Set_Modification_If_Complex_Properties_Changed() |
|
|
|
{ |
|
|
|
var street = Guid.NewGuid().ToString(); |
|
|
|
|
|
|
|
await WithUnitOfWorkAsync((async () => |
|
|
|
{ |
|
|
|
var douglas = await PersonRepository.GetAsync(TestDataBuilder.UserDouglasId); |
|
|
|
douglas.ContactInformation ??= new PersonContactInformation(); |
|
|
|
douglas.ContactInformation.Street = street; |
|
|
|
})); |
|
|
|
|
|
|
|
await WithUnitOfWorkAsync((async () => |
|
|
|
{ |
|
|
|
var douglas = await PersonRepository.FindAsync(TestDataBuilder.UserDouglasId); |
|
|
|
|
|
|
|
douglas.ShouldNotBeNull(); |
|
|
|
douglas.ContactInformation.ShouldNotBeNull(); |
|
|
|
douglas.ContactInformation!.Street.ShouldBe(street); |
|
|
|
douglas.LastModificationTime.ShouldNotBeNull(); |
|
|
|
douglas.LastModificationTime.Value.ShouldBeLessThanOrEqualTo(Clock.Now); |
|
|
|
douglas.LastModifierId.ShouldBe(CurrentUserId); |
|
|
|
})); |
|
|
|
|
|
|
|
EntityChangeEventHelper.Received().PublishEntityUpdatedEvent(Arg.Any<object>()); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task Should_Not_Set_Modification_If_Properties_HasDisableAuditing_UpdateModificationProps() |
|
|
|
{ |
|
|
|
@ -106,6 +134,28 @@ public class Auditing_Tests : Auditing_Tests<AbpEntityFrameworkCoreTestModule> |
|
|
|
EntityChangeEventHelper.Received().PublishEntityUpdatedEvent(Arg.Any<object>()); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task Should_Not_Set_Modification_If_ComplexProperties_HasDisableAuditing_UpdateModificationProps() |
|
|
|
{ |
|
|
|
await WithUnitOfWorkAsync((async () => |
|
|
|
{ |
|
|
|
var douglas = await PersonRepository.GetAsync(TestDataBuilder.UserDouglasId); |
|
|
|
douglas.ContactInformation ??= new PersonContactInformation(); |
|
|
|
douglas.ContactInformation.DisableAuditingUpdateModificationPropsProperty = Guid.NewGuid().ToString(); |
|
|
|
})); |
|
|
|
|
|
|
|
await WithUnitOfWorkAsync((async () => |
|
|
|
{ |
|
|
|
var douglas = await PersonRepository.FindAsync(TestDataBuilder.UserDouglasId); |
|
|
|
|
|
|
|
douglas.ShouldNotBeNull(); |
|
|
|
douglas.LastModificationTime.ShouldBeNull(); |
|
|
|
douglas.LastModifierId.ShouldBeNull(); |
|
|
|
})); |
|
|
|
|
|
|
|
EntityChangeEventHelper.Received().PublishEntityUpdatedEvent(Arg.Any<object>()); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task Should_Not_PublishEntityEvent_If_Properties_HasDisableAuditing_PublishEntityEventProperty() |
|
|
|
{ |
|
|
|
@ -126,6 +176,27 @@ public class Auditing_Tests : Auditing_Tests<AbpEntityFrameworkCoreTestModule> |
|
|
|
EntityChangeEventHelper.DidNotReceive().PublishEntityUpdatedEvent(Arg.Any<object>()); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task Should_Not_PublishEntityEvent_If_ComplexProperties_HasDisableAuditing_PublishEntityEventProperty() |
|
|
|
{ |
|
|
|
await WithUnitOfWorkAsync((async () => |
|
|
|
{ |
|
|
|
var douglas = await PersonRepository.GetAsync(TestDataBuilder.UserDouglasId); |
|
|
|
douglas.ContactInformation ??= new PersonContactInformation(); |
|
|
|
douglas.ContactInformation.DisableAuditingPublishEntityEventProperty = Guid.NewGuid().ToString(); |
|
|
|
})); |
|
|
|
|
|
|
|
await WithUnitOfWorkAsync((async () => |
|
|
|
{ |
|
|
|
var douglas = await PersonRepository.FindAsync(TestDataBuilder.UserDouglasId); |
|
|
|
|
|
|
|
douglas.ShouldNotBeNull(); |
|
|
|
douglas.LastModificationTime.ShouldNotBeNull(); |
|
|
|
})); |
|
|
|
|
|
|
|
EntityChangeEventHelper.DidNotReceive().PublishEntityUpdatedEvent(Arg.Any<object>()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task Should_Set_Modification_And_PublishEntityEvent_If_Properties_HasDisableAuditing() |
|
|
|
@ -146,4 +217,25 @@ public class Auditing_Tests : Auditing_Tests<AbpEntityFrameworkCoreTestModule> |
|
|
|
|
|
|
|
EntityChangeEventHelper.Received().PublishEntityUpdatedEvent(Arg.Any<object>()); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task Should_Set_Modification_And_PublishEntityEvent_If_ComplexProperties_HasDisableAuditing() |
|
|
|
{ |
|
|
|
await WithUnitOfWorkAsync((async () => |
|
|
|
{ |
|
|
|
var douglas = await PersonRepository.GetAsync(TestDataBuilder.UserDouglasId); |
|
|
|
douglas.ContactInformation ??= new PersonContactInformation(); |
|
|
|
douglas.ContactInformation.DisableAuditingProperty = Guid.NewGuid().ToString(); |
|
|
|
})); |
|
|
|
|
|
|
|
await WithUnitOfWorkAsync((async () => |
|
|
|
{ |
|
|
|
var douglas = await PersonRepository.FindAsync(TestDataBuilder.UserDouglasId); |
|
|
|
|
|
|
|
douglas.ShouldNotBeNull(); |
|
|
|
douglas.LastModificationTime.ShouldNotBeNull(); |
|
|
|
})); |
|
|
|
|
|
|
|
EntityChangeEventHelper.Received().PublishEntityUpdatedEvent(Arg.Any<object>()); |
|
|
|
} |
|
|
|
} |
|
|
|
|