feat(auditlog): scaffold ScadaLink.AuditLog project + tests project (#23)
This commit is contained in:
50
tests/ScadaLink.AuditLog.Tests/AddAuditLogTests.cs
Normal file
50
tests/ScadaLink.AuditLog.Tests/AddAuditLogTests.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Options;
|
||||
using ScadaLink.AuditLog.Configuration;
|
||||
|
||||
namespace ScadaLink.AuditLog.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// Bundle E (M1) smoke tests for the Audit Log (#23) DI scaffold. Verifies
|
||||
/// <c>AddAuditLog</c> registers <see cref="AuditLogOptions"/> against the
|
||||
/// <c>AuditLog</c> configuration section. Bundle E ships only the scaffold;
|
||||
/// the validator + full options surface land in Task 9.
|
||||
/// </summary>
|
||||
public class AddAuditLogTests
|
||||
{
|
||||
[Fact]
|
||||
public void AddAuditLog_RegistersAuditLogOptions()
|
||||
{
|
||||
var config = new ConfigurationBuilder()
|
||||
.AddInMemoryCollection(new Dictionary<string, string?>())
|
||||
.Build();
|
||||
|
||||
var services = new ServiceCollection();
|
||||
services.AddAuditLog(config);
|
||||
var provider = services.BuildServiceProvider();
|
||||
|
||||
var opts = provider.GetService<IOptions<AuditLogOptions>>();
|
||||
|
||||
Assert.NotNull(opts);
|
||||
Assert.NotNull(opts!.Value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddAuditLog_NullServices_Throws()
|
||||
{
|
||||
var config = new ConfigurationBuilder().Build();
|
||||
|
||||
Assert.Throws<ArgumentNullException>(
|
||||
() => ServiceCollectionExtensions.AddAuditLog(null!, config));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddAuditLog_NullConfig_Throws()
|
||||
{
|
||||
var services = new ServiceCollection();
|
||||
|
||||
Assert.Throws<ArgumentNullException>(
|
||||
() => services.AddAuditLog(null!));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user