203 lines
7.6 KiB
C#
203 lines
7.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 AccountDaoTest
|
|
{
|
|
private AccountDao _dao;
|
|
private Mock<ICoreSoapRequest> _mockCoreSoapRequest;
|
|
|
|
public AccountDaoTest()
|
|
{
|
|
_mockCoreSoapRequest = new Mock<ICoreSoapRequest>();
|
|
_dao = new AccountDao(_mockCoreSoapRequest.Object);
|
|
}
|
|
|
|
[TestMethod]
|
|
public void FindAccountByAccountNumber_OK()
|
|
{
|
|
var response = new AccountDetailInquiryResponse
|
|
{
|
|
WasSuccessful = true
|
|
};
|
|
|
|
_mockCoreSoapRequest.Setup(x => x.SubmitRequest<AccountDetailInquiryRequest, AccountDetailInquiryResponse>(It.Is<AccountDetailInquiryRequest>(req => req.AccountNumber == 100L && req.AvailableMethodCode.Equals("ABHP") && req.IsExternalEntity == false && req.IsGetRTXNData == false))).Returns(response).Verifiable();
|
|
|
|
var result = _dao.FindAccountByAccountNumber(100L);
|
|
_mockCoreSoapRequest.Verify();
|
|
|
|
Assert.IsNotNull(result);
|
|
Assert.IsTrue((bool)result.WasSuccessful);
|
|
}
|
|
|
|
[TestMethod]
|
|
public void FindAccountByAccountNumber_Exception()
|
|
{
|
|
|
|
_mockCoreSoapRequest.Setup(x => x.SubmitRequest<AccountDetailInquiryRequest, AccountDetailInquiryResponse>(It.IsAny<AccountDetailInquiryRequest>())).Throws(new Exception("Error thrown in unit test.")).Verifiable();
|
|
|
|
Assert.ThrowsException<Exception>(() => _dao.FindAccountByAccountNumber(100L));
|
|
_mockCoreSoapRequest.Verify();
|
|
}
|
|
|
|
[TestMethod]
|
|
public void SendAccountMaintenanceRequest_OK()
|
|
{
|
|
var maintenanceRequest = new AccountMaintenanceRequest
|
|
{
|
|
Accounts = new[]{
|
|
new MaintenanceAccount
|
|
{
|
|
AccountNumber = 123456,
|
|
DeliveryMethodCode = "PRNT"
|
|
}
|
|
}
|
|
};
|
|
|
|
var maintenanceResponse = new AccountMaintenanceResponse
|
|
{
|
|
WasSuccessful = true
|
|
};
|
|
|
|
_mockCoreSoapRequest.Setup(x => x.SubmitRequest<AccountMaintenanceRequest, AccountMaintenanceResponse>(maintenanceRequest)).Returns(maintenanceResponse).Verifiable();
|
|
|
|
var result = _dao.SendAccountMaintenanceRequest(maintenanceRequest);
|
|
Assert.IsNotNull(result);
|
|
Assert.IsTrue((bool)result.WasSuccessful);
|
|
_mockCoreSoapRequest.Verify();
|
|
}
|
|
|
|
[TestMethod]
|
|
public void SendAccountMaintenanceRequest_Exception()
|
|
{
|
|
var maintenanceRequest = new AccountMaintenanceRequest
|
|
{
|
|
Accounts = new[]{
|
|
new MaintenanceAccount
|
|
{
|
|
AccountNumber = 123456,
|
|
DeliveryMethodCode = "PRNT"
|
|
}
|
|
}
|
|
};
|
|
|
|
_mockCoreSoapRequest.Setup(x => x.SubmitRequest<AccountMaintenanceRequest, AccountMaintenanceResponse>(maintenanceRequest)).Throws(new Exception("Error thrown in unit test.")).Verifiable();
|
|
|
|
Assert.ThrowsException<Exception>(() => _dao.SendAccountMaintenanceRequest(maintenanceRequest));
|
|
_mockCoreSoapRequest.Verify();
|
|
}
|
|
|
|
[TestMethod]
|
|
public void SendAccountNickNameUpdateRequest_OK()
|
|
{
|
|
var maintenanceRequest = new AccountMaintenanceRequest
|
|
{
|
|
Accounts = new[]{
|
|
new MaintenanceAccount
|
|
{
|
|
AccountNumber = 123456,
|
|
AccountDescription = "TestSuccess"
|
|
}
|
|
}
|
|
};
|
|
|
|
var maintenanceResponse = new AccountMaintenanceResponse
|
|
{
|
|
WasSuccessful = true
|
|
};
|
|
|
|
_mockCoreSoapRequest.Setup(x => x.SubmitRequest<AccountMaintenanceRequest, AccountMaintenanceResponse>(maintenanceRequest)).Returns(maintenanceResponse).Verifiable();
|
|
|
|
var result = _dao.SendAccountMaintenanceRequest(maintenanceRequest);
|
|
Assert.IsNotNull(result);
|
|
Assert.IsTrue((bool)result.WasSuccessful);
|
|
_mockCoreSoapRequest.Verify();
|
|
}
|
|
|
|
[TestMethod]
|
|
public void SendAccountNickNameUpdateRequest_Exception()
|
|
{
|
|
var maintenanceRequest = new AccountMaintenanceRequest
|
|
{
|
|
Accounts = new[]{
|
|
new MaintenanceAccount
|
|
{
|
|
AccountNumber = 123456,
|
|
AccountDescription = "TestException"
|
|
}
|
|
}
|
|
};
|
|
|
|
_mockCoreSoapRequest.Setup(x => x.SubmitRequest<AccountMaintenanceRequest, AccountMaintenanceResponse>(maintenanceRequest)).Throws(new Exception("Error thrown in unit test.")).Verifiable();
|
|
|
|
Assert.ThrowsException<Exception>(() => _dao.SendAccountMaintenanceRequest(maintenanceRequest));
|
|
_mockCoreSoapRequest.Verify();
|
|
}
|
|
|
|
[TestMethod]
|
|
public void SendAccountCreditReportTypeUpdateRequest_OK()
|
|
{
|
|
var maintenanceRequest = new AccountMaintenanceRequest
|
|
{
|
|
Accounts = new[]{
|
|
new MaintenanceAccount
|
|
{
|
|
AccountNumber = 123456,
|
|
IsAccountMaintenance = true,
|
|
AccountLoanDetail = new AccountLoanDetail()
|
|
{
|
|
AccountLoanInformation = new AccountLoanInformation()
|
|
{
|
|
CreditReportTypeCode = "EXCL"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
var maintenanceResponse = new AccountMaintenanceResponse
|
|
{
|
|
WasSuccessful = true
|
|
};
|
|
|
|
_mockCoreSoapRequest.Setup(x => x.SubmitRequest<AccountMaintenanceRequest, AccountMaintenanceResponse>(maintenanceRequest)).Returns(maintenanceResponse).Verifiable();
|
|
|
|
var result = _dao.SendAccountMaintenanceRequest(maintenanceRequest);
|
|
Assert.IsNotNull(result);
|
|
Assert.IsTrue((bool)result.WasSuccessful);
|
|
_mockCoreSoapRequest.Verify();
|
|
}
|
|
|
|
[TestMethod]
|
|
public void SendAccountCreditReportTypeUpdateRequest_Exception()
|
|
{
|
|
var maintenanceRequest = new AccountMaintenanceRequest
|
|
{
|
|
Accounts = new[]{
|
|
new MaintenanceAccount
|
|
{
|
|
AccountNumber = 123456,
|
|
IsAccountMaintenance = true,
|
|
AccountLoanDetail = new AccountLoanDetail()
|
|
{
|
|
AccountLoanInformation = new AccountLoanInformation()
|
|
{
|
|
CreditReportTypeCode = "EXCL"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
_mockCoreSoapRequest.Setup(x => x.SubmitRequest<AccountMaintenanceRequest, AccountMaintenanceResponse>(maintenanceRequest)).Throws(new Exception("Error thrown in unit test.")).Verifiable();
|
|
|
|
Assert.ThrowsException<Exception>(() => _dao.SendAccountMaintenanceRequest(maintenanceRequest));
|
|
_mockCoreSoapRequest.Verify();
|
|
}
|
|
}
|
|
} |