This commit is contained in:
Zeeshaun
2026-03-13 09:11:35 -05:00
parent f004c8205a
commit c2d6bda458
197 changed files with 14970 additions and 0 deletions
@@ -0,0 +1,57 @@
using LCU.API.Internal.DocumentLib.Containers;
using Microsoft.Extensions.Logging;
using OwnerNumberMigration.Logging;
using OwnerNumberMigrationTest.TestDataFactories;
using OwnerNumberMigrationTest.TestDoubles;
namespace OwnerNumberMigrationTest.Logging;
public class AttributeMigrationLoggingObserverTest
{
private readonly IObserver<DocumentInformation> _observer;
private readonly FakeLogger _logger = new();
private readonly string _attributeName = Guid.NewGuid().ToString();
public AttributeMigrationLoggingObserverTest()
{
_observer = new AttributeMigrationLoggingObserver(_logger, _attributeName);
}
[Test]
public void OnCompleted_AllCases_InfoLogsCompletedAttribute()
{
_observer.OnCompleted();
Func<Log, bool> logMatch = l => l.LogLevel == LogLevel.Information
&& l.Message.Contains("completed", StringComparison.OrdinalIgnoreCase)
&& l.Message.Contains(_attributeName);
Assert.IsTrue(_logger.Logs.Count(logMatch) == 1);
}
[Test]
public void OnError_AllCases_ErrorLogsExceptionAndAttribute()
{
var error = new Exception(Guid.NewGuid().ToString());
_observer.OnError(error);
Func<Log, bool> logMatch = l => l.LogLevel == LogLevel.Error
&& l.Message.Contains(error.Message)
&& l.Message.Contains(_attributeName);
Assert.IsTrue(_logger.Logs.Count(logMatch) == 1);
}
[Test]
public void OnNext_AllCases_InfoLogsStartingAttributeAndDocumentId()
{
var document = DocumentInformationFactory.CreateDocumentInformation();
_observer.OnNext(document);
Func<Log, bool> logMatch = l => l.LogLevel == LogLevel.Information
&& l.Message.Contains(document.DocumentId.ToString())
&& l.Message.Contains(_attributeName);
Assert.IsTrue(_logger.Logs.Count(logMatch) == 1);
}
}