Browse Source

audit logging module unit-test (bugged atm)

pull/395/head
Yunus Emre Kalkan 8 years ago
parent
commit
6e3f53b1a1
  1. 2
      modules/audit-logging/test/Volo.Abp.AuditLogging.Tests/Volo/Abp/AuditLogging/AuditLogsTestBase.cs
  2. 23
      modules/audit-logging/test/Volo.Abp.AuditLogging.Tests/Volo/Abp/AuditLogging/AuditStore_Basic_Tests.cs

2
modules/audit-logging/test/Volo.Abp.AuditLogging.Tests/Volo/Abp/AuditLogging/AuditLogsTestBase.cs

@ -23,7 +23,7 @@ namespace Volo.Abp.AuditLogging
}
}
protected List<AuditLog> GetSAuditLogsFromDbContext()
protected List<AuditLog> GetAuditLogsFromDbContext()
{
return UsingDbContext(context =>
context.AuditLogs.ToList()

23
modules/audit-logging/test/Volo.Abp.AuditLogging.Tests/Volo/Abp/AuditLogging/AuditStore_Basic_Tests.cs

@ -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);
}
}
}

Loading…
Cancel
Save