77 lines
2.9 KiB
C#
77 lines
2.9 KiB
C#
using System.Linq;
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using NUnit.Framework;
|
|
using Moq;
|
|
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels;
|
|
using LCU.Api.Internal.CoreApiWrapper.Services;
|
|
using LCU.Library.Internal.CoreApiWrapperLib.DataAccess;
|
|
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Tax;
|
|
|
|
namespace LCU.Api.Internal.CoreApiWrapperTest.Service
|
|
{
|
|
public class TaxServiceTest
|
|
{
|
|
private readonly TaxService _taxService;
|
|
private readonly Mock<ITaxDao> _mockTaxDao;
|
|
|
|
public TaxServiceTest()
|
|
{
|
|
_mockTaxDao = new Mock<ITaxDao>();
|
|
_taxService = new TaxService(_mockTaxDao.Object);
|
|
}
|
|
|
|
[Test]
|
|
public async Task GetPersonsTaxIdData_Returns_PersonTaxIdData()
|
|
{
|
|
var personTaxIdDataResponse = new List<PersonTaxIdDataResponse>
|
|
{
|
|
new() {
|
|
FirstName = "Greg",
|
|
MiddleInitial = "H",
|
|
LastName = "Stevens",
|
|
Suffix = "Jr.",
|
|
NameFull = "Greg H. Stevens Jr.",
|
|
PersonNumber = 123
|
|
}
|
|
};
|
|
|
|
_mockTaxDao.Setup(x => x.GetPersonTaxIdData(It.IsAny<CoreRequestParameters>(), It.Is<string>(x => x == "123"))).ReturnsAsync(personTaxIdDataResponse).Verifiable();
|
|
var result = await _taxService.GetPersonsTaxIdData("123");
|
|
|
|
Assert.NotNull(result);
|
|
Assert.AreEqual(1, result.Count());
|
|
var firstResponse = result.First();
|
|
Assert.AreEqual("Greg",firstResponse.FirstName);
|
|
Assert.AreEqual("H", firstResponse.MiddleInitial);
|
|
Assert.AreEqual("Stevens", firstResponse.LastName);
|
|
Assert.AreEqual("Jr.", firstResponse.Suffix);
|
|
Assert.AreEqual("Greg H. Stevens Jr.", firstResponse.NameFull);
|
|
Assert.AreEqual(123, firstResponse.PersonNumber);
|
|
_mockTaxDao.Verify();
|
|
}
|
|
|
|
[Test]
|
|
public async Task GetOrganizationsTaxIdData_Returns_OrganizationTaxIdData()
|
|
{
|
|
var organizationsTaxIdDataResponse = new List<OrganizationTaxIdDataResponse>
|
|
{
|
|
new() {
|
|
Name = "Electric Company",
|
|
OrganizationNumber = 123
|
|
}
|
|
};
|
|
|
|
_mockTaxDao.Setup(x => x.GetOrganizationTaxIdData(It.IsAny<CoreRequestParameters>(), It.Is<string>(x => x == "123"))).ReturnsAsync(organizationsTaxIdDataResponse).Verifiable();
|
|
var result = await _taxService.GetOrganizationsTaxIdData("123");
|
|
|
|
Assert.NotNull(result);
|
|
Assert.AreEqual(1, result.Count());
|
|
var firstResponse = result.First();
|
|
Assert.AreEqual("Electric Company",firstResponse.Name);
|
|
Assert.AreEqual(123, firstResponse.OrganizationNumber);
|
|
_mockTaxDao.Verify();
|
|
}
|
|
}
|
|
}
|