Adding
This commit is contained in:
+52
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using NUnit.Framework;
|
||||
using Moq;
|
||||
using LCU.Api.Internal.CoreApiWrapper.Services;
|
||||
using LCU.Library.Internal.CoreApiWrapperLib.DataAccess;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Associate;
|
||||
using LCU.Library.Internal.Exceptions;
|
||||
|
||||
namespace LCU.Api.Internal.CoreApiWrapperTest.Service
|
||||
{
|
||||
public class AssociateServiceTest
|
||||
{
|
||||
private readonly AssociateService _associateService;
|
||||
private readonly Mock<IAssociateDao> _mockAssociateDao;
|
||||
|
||||
public AssociateServiceTest()
|
||||
{
|
||||
_mockAssociateDao = new Mock<IAssociateDao>();
|
||||
_associateService = new AssociateService(_mockAssociateDao.Object);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetAssociateDetailsBySsn_Exception_Returns_Null()
|
||||
{
|
||||
var taxId = Guid.NewGuid().ToString();
|
||||
|
||||
_mockAssociateDao.Setup(x => x.GetAssociateDetailsBySsn(It.IsAny<string>())).Throws(new Exception());
|
||||
|
||||
Assert.ThrowsAsync<ServiceException>(() => _associateService.GetAssociateDetailsBySsn(taxId));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetAssociateDetailsBySsn_Returns_PersonAssociateDetails()
|
||||
{
|
||||
var taxId = Guid.NewGuid().ToString();
|
||||
|
||||
var associateDetails = new AssociateDetails
|
||||
{
|
||||
PersonNumber = DateTime.Now.Millisecond
|
||||
};
|
||||
|
||||
_mockAssociateDao.Setup(x => x.GetAssociateDetailsBySsn(It.IsAny<string>())).ReturnsAsync(associateDetails).Verifiable();
|
||||
|
||||
var result = await _associateService.GetAssociateDetailsBySsn(taxId);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(associateDetails.PersonNumber, result.PersonNumber);
|
||||
_mockAssociateDao.Verify();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user