Files
2026-03-13 09:28:55 -05:00

84 lines
3.1 KiB
C#

using Moq;
using NUnit.Framework;
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Api.Internal.DataCleanUp.Services;
using LCU.Api.Internal.DataCleanUp.DataAccess;
using LCU.Library.Internal.DataCleanUpModel.Enum;
using LCU.Library.Internal.DataCleanUpModel.Models;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreResponses;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreRequests;
using LCU.Api.Internal.DataCleanUp.Configuration;
namespace LCU.Api.Internal.DataCleanUpTest.Services;
public class UpdateAccountGroupForAnalysisServiceTest
{
private UpdateAccountGroupForAnalysisService _updateAccountGroupForAnalysisService;
private Mock<ICoreApiWrapperService> _mockCoreApiWrapperService;
private Mock<ICoreApiWrapperDao> _mockCoreApiWrapperDao;
private DataCleanupDefaults _dataCleanUpDefaults;
[SetUp]
public void Setup()
{
_dataCleanUpDefaults = new DataCleanupDefaults();
_mockCoreApiWrapperDao = new Mock<ICoreApiWrapperDao>();
_mockCoreApiWrapperService = new Mock<ICoreApiWrapperService>();
_updateAccountGroupForAnalysisService = new UpdateAccountGroupForAnalysisService(_mockCoreApiWrapperService.Object, _dataCleanUpDefaults);
}
[Test]
public async Task CleanUpAccountGroups_Success()
{
var listAccounts = new List<string>() { "23" };
_mockCoreApiWrapperService.Setup(x => x.GetGroupUpdateForAnalysisAccountNumbers()).ReturnsAsync(listAccounts);
//Set Up Response
var basicResponse = new BasicResponse()
{
Success = true,
Errors = new List<string>()
};
_mockCoreApiWrapperService.Setup(x => x.UpdateAccountGroupForAnalysis(It.IsAny<string>()))
.ReturnsAsync(basicResponse);
var testRequest = new DataCleanUpRequest()
{
CleanUpType = CleanUpTypes.UpdateAccountGroupForAnalysis
};
var result = await _updateAccountGroupForAnalysisService.CleanUp(testRequest);
Assert.NotNull(result);
Assert.AreEqual(testRequest, result.Request);
Assert.IsTrue(result.Successful);
Assert.IsEmpty(result.ResponseStack);
_mockCoreApiWrapperService.Verify(x => x.UpdateAccountGroupForAnalysis(It.IsAny<string>()), Times.Once);
}
[Test]
public async Task CleanUpAccountGroups_Fail()
{
//Set Up Object
var basicResponse = new BasicResponse();
_mockCoreApiWrapperService.Setup(x => x.UpdateAccountGroupForAnalysis(It.IsAny<string>()))
.ReturnsAsync(basicResponse);
var testRequest = new DataCleanUpRequest()
{
CleanUpType = CleanUpTypes.UpdateAccountGroupForAnalysis
};
var result = await _updateAccountGroupForAnalysisService.CleanUp(testRequest);
Assert.NotNull(result);
Assert.AreEqual(testRequest, result.Request);
Assert.AreEqual(0, result.ResponseStack.Count);
_mockCoreApiWrapperDao.Verify(x => x.UpdateAccountGroupForAnalysis(It.IsAny<AccountAnalysisGroupMaintenanceRequest>()), Times.Never);
}
}