using LCU.API.Internal.CoreSoapApiWrapper.CoreSoapUtilities; using LCU.API.Internal.CoreSoapApiWrapper.DataAccess; using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; using System; namespace LCU.API.Internal.CoreSoapApiWrapperTest.DataAccess { [TestClass] public class TaxDaoTest { private readonly TaxDao _dao; private readonly Mock _mockCoreSoapRequest; public TaxDaoTest() { _mockCoreSoapRequest = new Mock(); _dao = new TaxDao(_mockCoreSoapRequest.Object); } [TestMethod] public void GetTaxIdData_OK() { var response = new GetTaxIdDataResponse { WasSuccessful = true }; _mockCoreSoapRequest.Setup(x => x.SubmitRequest(It.Is(req => req.ReferenceNumber== "100" && req.MethodNumber == 1))).Returns(response).Verifiable(); var result = _dao.GetTaxIdData(100L); _mockCoreSoapRequest.Verify(); Assert.IsNotNull(result); Assert.IsTrue((bool)result.WasSuccessful); } [TestMethod] public void GetTaxIdData_Exception() { _mockCoreSoapRequest.Setup(x => x.SubmitRequest(It.IsAny())).Throws(new Exception("Error thrown in unit test.")).Verifiable(); Assert.ThrowsException(() => _dao.GetTaxIdData(100L)); _mockCoreSoapRequest.Verify(); } } }