|
|
@ -720,6 +720,104 @@ public class Auditing_Tests : AbpAuditingTestBase |
|
|
x.EntityChanges[1].PropertyChanges[0].PropertyName == nameof(AppEntityWithNavigationChildManyToMany.ManyToMany) && |
|
|
x.EntityChanges[1].PropertyChanges[0].PropertyName == nameof(AppEntityWithNavigationChildManyToMany.ManyToMany) && |
|
|
x.EntityChanges[1].PropertyChanges[0].PropertyTypeFullName == typeof(List<AppEntityWithNavigations>).FullName)); |
|
|
x.EntityChanges[1].PropertyChanges[0].PropertyTypeFullName == typeof(List<AppEntityWithNavigations>).FullName)); |
|
|
|
|
|
|
|
|
|
|
|
#pragma warning restore 4014
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Fact] |
|
|
|
|
|
public async Task Should_Write_AuditLog_For_Json_Property_Changes() |
|
|
|
|
|
{ |
|
|
|
|
|
var entityId = Guid.NewGuid(); |
|
|
|
|
|
var repository = ServiceProvider.GetRequiredService<IBasicRepository<AppEntityWithJsonProperty, Guid>>(); |
|
|
|
|
|
|
|
|
|
|
|
using (var scope = _auditingManager.BeginScope()) |
|
|
|
|
|
{ |
|
|
|
|
|
using (var uow = _unitOfWorkManager.Begin()) |
|
|
|
|
|
{ |
|
|
|
|
|
var entity = new AppEntityWithJsonProperty(entityId, "Test Entity") |
|
|
|
|
|
{ |
|
|
|
|
|
Data = new JsonPropertyObject() |
|
|
|
|
|
{ |
|
|
|
|
|
{ "Name", "String Name" }, |
|
|
|
|
|
{ "Value", "String Value"} |
|
|
|
|
|
}, |
|
|
|
|
|
Count = 10 |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
await repository.InsertAsync(entity); |
|
|
|
|
|
|
|
|
|
|
|
await uow.CompleteAsync(); |
|
|
|
|
|
await scope.SaveAsync(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#pragma warning disable 4014
|
|
|
|
|
|
AuditingStore.Received().SaveAsync(Arg.Is<AuditLogInfo>(x => x.EntityChanges.Count == 1 && |
|
|
|
|
|
x.EntityChanges[0].ChangeType == EntityChangeType.Created && |
|
|
|
|
|
x.EntityChanges[0].EntityTypeFullName == typeof(AppEntityWithJsonProperty).FullName && |
|
|
|
|
|
x.EntityChanges[0].PropertyChanges.Count == 4 && |
|
|
|
|
|
|
|
|
|
|
|
x.EntityChanges[0].PropertyChanges[0].OriginalValue == null && |
|
|
|
|
|
x.EntityChanges[0].PropertyChanges[0].NewValue == "10" && |
|
|
|
|
|
x.EntityChanges[0].PropertyChanges[0].PropertyName == nameof(AppEntityWithJsonProperty.Count) && |
|
|
|
|
|
x.EntityChanges[0].PropertyChanges[0].PropertyTypeFullName == typeof(int).FullName && |
|
|
|
|
|
|
|
|
|
|
|
x.EntityChanges[0].PropertyChanges[1].OriginalValue == null && |
|
|
|
|
|
x.EntityChanges[0].PropertyChanges[1].NewValue == "\"Test Entity\"" && |
|
|
|
|
|
x.EntityChanges[0].PropertyChanges[1].PropertyName == nameof(AppEntityWithJsonProperty.Name) && |
|
|
|
|
|
x.EntityChanges[0].PropertyChanges[1].PropertyTypeFullName == typeof(string).FullName && |
|
|
|
|
|
|
|
|
|
|
|
x.EntityChanges[0].PropertyChanges[2].OriginalValue == null && |
|
|
|
|
|
x.EntityChanges[0].PropertyChanges[2].NewValue == "\"String Name\"" && |
|
|
|
|
|
x.EntityChanges[0].PropertyChanges[2].PropertyName == "Data.Name" && |
|
|
|
|
|
x.EntityChanges[0].PropertyChanges[2].PropertyTypeFullName == typeof(string).FullName && |
|
|
|
|
|
|
|
|
|
|
|
x.EntityChanges[0].PropertyChanges[3].OriginalValue == null && |
|
|
|
|
|
x.EntityChanges[0].PropertyChanges[3].NewValue == "\"String Value\"" && |
|
|
|
|
|
x.EntityChanges[0].PropertyChanges[3].PropertyName == "Data.Value" && |
|
|
|
|
|
x.EntityChanges[0].PropertyChanges[3].PropertyTypeFullName == typeof(string).FullName)); |
|
|
|
|
|
AuditingStore.ClearReceivedCalls(); |
|
|
|
|
|
#pragma warning restore 4014
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using (var scope = _auditingManager.BeginScope()) |
|
|
|
|
|
{ |
|
|
|
|
|
using (var uow = _unitOfWorkManager.Begin()) |
|
|
|
|
|
{ |
|
|
|
|
|
var entity = await repository.GetAsync(entityId); |
|
|
|
|
|
|
|
|
|
|
|
entity.Name = "Updated Test Entity"; |
|
|
|
|
|
|
|
|
|
|
|
entity.Data["Name"] = "Updated String Name"; |
|
|
|
|
|
entity.Data["Value"] = "Updated String Value"; |
|
|
|
|
|
|
|
|
|
|
|
await repository.UpdateAsync(entity); |
|
|
|
|
|
|
|
|
|
|
|
await uow.CompleteAsync(); |
|
|
|
|
|
await scope.SaveAsync(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#pragma warning disable 4014
|
|
|
|
|
|
AuditingStore.Received().SaveAsync(Arg.Is<AuditLogInfo>(x => x.EntityChanges.Count == 1 && |
|
|
|
|
|
x.EntityChanges[0].ChangeType == EntityChangeType.Updated && |
|
|
|
|
|
x.EntityChanges[0].EntityTypeFullName == typeof(AppEntityWithJsonProperty).FullName && |
|
|
|
|
|
x.EntityChanges[0].PropertyChanges.Count == 3 && |
|
|
|
|
|
|
|
|
|
|
|
x.EntityChanges[0].PropertyChanges[0].OriginalValue == "\"Test Entity\"" && |
|
|
|
|
|
x.EntityChanges[0].PropertyChanges[0].NewValue == "\"Updated Test Entity\"" && |
|
|
|
|
|
x.EntityChanges[0].PropertyChanges[0].PropertyName == nameof(AppEntityWithJsonProperty.Name) && |
|
|
|
|
|
x.EntityChanges[0].PropertyChanges[0].PropertyTypeFullName == typeof(string).FullName && |
|
|
|
|
|
|
|
|
|
|
|
x.EntityChanges[0].PropertyChanges[1].OriginalValue == "\"String Name\"" && |
|
|
|
|
|
x.EntityChanges[0].PropertyChanges[1].NewValue == "\"Updated String Name\"" && |
|
|
|
|
|
x.EntityChanges[0].PropertyChanges[1].PropertyName == "Data.Name" && |
|
|
|
|
|
x.EntityChanges[0].PropertyChanges[1].PropertyTypeFullName == typeof(string).FullName && |
|
|
|
|
|
|
|
|
|
|
|
x.EntityChanges[0].PropertyChanges[2].OriginalValue == "\"String Value\"" && |
|
|
|
|
|
x.EntityChanges[0].PropertyChanges[2].NewValue == "\"Updated String Value\"" && |
|
|
|
|
|
x.EntityChanges[0].PropertyChanges[2].PropertyName == "Data.Value" && |
|
|
|
|
|
x.EntityChanges[0].PropertyChanges[2].PropertyTypeFullName == typeof(string).FullName)); |
|
|
|
|
|
AuditingStore.ClearReceivedCalls(); |
|
|
#pragma warning restore 4014
|
|
|
#pragma warning restore 4014
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|