|
|
|
@ -1,5 +1,8 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Shouldly; |
|
|
|
using Volo.Abp.Auditing; |
|
|
|
using Xunit; |
|
|
|
|
|
|
|
@ -18,24 +21,34 @@ namespace Volo.Abp.AuditLogging |
|
|
|
public async Task Should_Save_A_Audit_Log() |
|
|
|
{ |
|
|
|
//Arrange
|
|
|
|
var auditLog = new AuditLogInfo() |
|
|
|
var userId = new Guid("4456fb0d-74cc-4807-9eee-23e551e6cb06"); |
|
|
|
var ipAddress = "153.1.7.61"; |
|
|
|
var firstComment = "first Comment"; |
|
|
|
|
|
|
|
var auditLog = new AuditLogInfo |
|
|
|
{ |
|
|
|
TenantId = Guid.NewGuid(), |
|
|
|
UserId = Guid.NewGuid(), |
|
|
|
UserId = userId, |
|
|
|
ImpersonatorUserId = Guid.NewGuid(), |
|
|
|
ImpersonatorTenantId = Guid.NewGuid(), |
|
|
|
ExecutionTime = DateTime.Today, |
|
|
|
ExecutionDuration = 42, |
|
|
|
ClientIpAddress = "153.1.7.61", |
|
|
|
ClientIpAddress = ipAddress, |
|
|
|
ClientName = "MyDesktop", |
|
|
|
BrowserInfo = "Chrome" |
|
|
|
BrowserInfo = "Chrome", |
|
|
|
Comments = new List<string> { firstComment, "Second Comment"} |
|
|
|
}; |
|
|
|
|
|
|
|
//Act
|
|
|
|
await _auditingStore.SaveAsync(auditLog); |
|
|
|
|
|
|
|
//Assert
|
|
|
|
//TODO:...
|
|
|
|
|
|
|
|
var insertedLog = GetAuditLogsFromDbContext().FirstOrDefault(al => al.UserId == userId); |
|
|
|
|
|
|
|
insertedLog.ShouldNotBeNull(); |
|
|
|
insertedLog.ClientIpAddress.ShouldBe(ipAddress); |
|
|
|
insertedLog.Comments.ShouldStartWith(firstComment); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|