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 _mockAssociateDao; public AssociateServiceTest() { _mockAssociateDao = new Mock(); _associateService = new AssociateService(_mockAssociateDao.Object); } [Test] public void GetAssociateDetailsBySsn_Exception_Returns_Null() { var taxId = Guid.NewGuid().ToString(); _mockAssociateDao.Setup(x => x.GetAssociateDetailsBySsn(It.IsAny())).Throws(new Exception()); Assert.ThrowsAsync(() => _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())).ReturnsAsync(associateDetails).Verifiable(); var result = await _associateService.GetAssociateDetailsBySsn(taxId); Assert.NotNull(result); Assert.AreEqual(associateDetails.PersonNumber, result.PersonNumber); _mockAssociateDao.Verify(); } } }