Files
monorepo/LCU.Api.Internal.CoreApiWrapper/LCU.Api.Internal.CoreApiWrapperTest/DataAccess/TaxDaoTest.cs
T
2026-03-31 14:32:23 -05:00

96 lines
3.7 KiB
C#

using System.Collections.Generic;
using System.Threading.Tasks;
using System.Linq;
using Moq;
using NUnit.Framework;
using LCU.Library.Internal.CoreApiWrapperLib.DataAccess;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels;
using LCU.Library.Internal.CoreApiWrapperLib.Configuration;
using LCU.Library.Internal.CoreApiWrapperLib.CoreApiUtilities;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Tax;
namespace LCU.Api.Internal.CoreApiWrapperTest.DataAccess
{
public class TaxDaoTest
{
private TaxDao _taxDao;
private Mock<ICoreRequest> _mockCoreRequest;
private CoreConfiguration _coreConfiguration;
[SetUp]
public void SetUp()
{
_mockCoreRequest = new Mock<ICoreRequest>();
_coreConfiguration = new CoreConfiguration
{
CoreApiConfiguration = new CoreApiConfiguration
{
CoreEndPointConfiguration = new CoreEndPointConfiguration
{
GetOrganizationsDataByTaxId = "test/Organization/Query/TaxId",
GetPersonsDataByTaxId = "test/Person/Query/TaxId"
}
}
};
_taxDao = new TaxDao(_mockCoreRequest.Object, _coreConfiguration);
}
[Test]
public async Task GetPersonTaxIdData_Returns_Success()
{
var header = new CoreMessageHeader
{
UpdateKey = null,
MessageId = null
};
var body = new List<PersonTaxIdDataResponse>{
new()
{
FirstName = "Greg",
MiddleInitial = "H",
LastName = "Stevens",
Suffix = "Jr.",
NameFull = "Greg H. Stevens Jr.",
PersonNumber = 123
}
};
var personTaxIdDataResponse = new CoreApiMessage<IEnumerable<PersonTaxIdDataResponse>>(header, body);
_mockCoreRequest.Setup(x => x.PostRequestObject<CoreApiMessage<IEnumerable<PersonTaxIdDataResponse>>>(It.Is<string>(url => url.Equals("test/Person/Query/TaxId")), It.IsAny<Dictionary<string, string>>() ,It.Is<string>(x => x.Contains("123")))).ReturnsAsync(personTaxIdDataResponse).Verifiable();
var results = await _taxDao.GetPersonTaxIdData(new CoreRequestParameters(), "123");
Assert.IsNotNull(results);
Assert.AreEqual(1, results.Count());
_mockCoreRequest.Verify();
}
[Test]
public async Task GetOrganizationTaxIdData_Returns_Success()
{
var header = new CoreMessageHeader
{
UpdateKey = null,
MessageId = null
};
var body = new List<OrganizationTaxIdDataResponse>{
new()
{
Name = "Organization",
OrganizationNumber = 123
}
};
var personTaxIdDataResponse = new CoreApiMessage<IEnumerable<OrganizationTaxIdDataResponse>>(header, body);
_mockCoreRequest.Setup(x => x.PostRequestObject<CoreApiMessage<IEnumerable<OrganizationTaxIdDataResponse>>>(It.Is<string>(url => url.Equals("test/Organization/Query/TaxId")), It.IsAny<Dictionary<string, string>>() ,It.Is<string>(url => url.Contains("123")))).ReturnsAsync(personTaxIdDataResponse).Verifiable();
var results = await _taxDao.GetOrganizationTaxIdData(new CoreRequestParameters(), "123");
Assert.IsNotNull(results);
Assert.AreEqual(1, results.Count());
_mockCoreRequest.Verify();
}
}
}