48 lines
1.6 KiB
C#
48 lines
1.6 KiB
C#
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<ICoreSoapRequest> _mockCoreSoapRequest;
|
|
|
|
public TaxDaoTest()
|
|
{
|
|
_mockCoreSoapRequest = new Mock<ICoreSoapRequest>();
|
|
_dao = new TaxDao(_mockCoreSoapRequest.Object);
|
|
}
|
|
|
|
[TestMethod]
|
|
public void GetTaxIdData_OK()
|
|
{
|
|
var response = new GetTaxIdDataResponse
|
|
{
|
|
WasSuccessful = true
|
|
};
|
|
|
|
_mockCoreSoapRequest.Setup(x => x.SubmitRequest<GetTaxIdDataRequest, GetTaxIdDataResponse>(It.Is<GetTaxIdDataRequest>(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<GetTaxIdDataRequest, GetTaxIdDataResponse>(It.IsAny<GetTaxIdDataRequest>())).Throws(new Exception("Error thrown in unit test.")).Verifiable();
|
|
|
|
Assert.ThrowsException<Exception>(() => _dao.GetTaxIdData(100L));
|
|
_mockCoreSoapRequest.Verify();
|
|
}
|
|
}
|
|
} |