Adding
This commit is contained in:
+203
@@ -0,0 +1,203 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
+135
@@ -0,0 +1,135 @@
|
||||
using LCU.API.Internal.CoreSoapApiWrapper.CoreSoapUtilities;
|
||||
using LCU.API.Internal.CoreSoapApiWrapper.DataAccess;
|
||||
using LCU.API.Internal.CoreSoapApiWrapper.Models.Requests;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LCU.API.Internal.CoreSoapApiWrapperTest.DataAccess
|
||||
{
|
||||
[TestClass]
|
||||
public class CollateralMaintenanceDaoTest
|
||||
{
|
||||
private CollateralMaintenanceDao _dao;
|
||||
private Mock<ICoreSoapRequest> _mockCoreSoapRequest;
|
||||
|
||||
public CollateralMaintenanceDaoTest()
|
||||
{
|
||||
_mockCoreSoapRequest = new Mock<ICoreSoapRequest>();
|
||||
_dao = new CollateralMaintenanceDao(_mockCoreSoapRequest.Object);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void FindPropertyByPropertyNumber_OK()
|
||||
{
|
||||
var response = new CollateralSearchResponse
|
||||
{
|
||||
WasSuccessful = true
|
||||
};
|
||||
|
||||
_mockCoreSoapRequest.Setup(x => x.SubmitRequest<CollateralSearchRequest, CollateralSearchResponse>(It.Is<CollateralSearchRequest>(req => req.PropertyCollateral.PropertyNumber == 100000))).Returns(response).Verifiable();
|
||||
|
||||
var result = _dao.FindCollateralMaintenanceByPropertyNumber(100000);
|
||||
_mockCoreSoapRequest.Verify();
|
||||
|
||||
Assert.IsNotNull(result);
|
||||
Assert.IsTrue((bool)result.WasSuccessful);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void FindPropertyByPropertyNumber_Exception()
|
||||
{
|
||||
|
||||
_mockCoreSoapRequest.Setup(x => x.SubmitRequest<CollateralSearchRequest, CollateralSearchResponse>(It.IsAny<CollateralSearchRequest>())).Throws(new Exception("Error thrown in unit test.")).Verifiable();
|
||||
|
||||
Assert.ThrowsException<Exception>(() => _dao.FindCollateralMaintenanceByPropertyNumber(100000));
|
||||
_mockCoreSoapRequest.Verify();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void AddCollateralMaintenanceRequest_OK()
|
||||
{
|
||||
UserFieldRequest request = new UserFieldRequest()
|
||||
{
|
||||
PropertyNumber = 1,
|
||||
UserFieldCode = "Test",
|
||||
Value = "Test"
|
||||
};
|
||||
|
||||
var maintenanceRequest = CreateCollateralMaintenanceRequest.CreateMaintenanceRequest(request);
|
||||
var maintenanceResponse = new CollateralMaintenanceResponse
|
||||
{
|
||||
WasSuccessful = true
|
||||
};
|
||||
|
||||
_mockCoreSoapRequest.Setup(x => x.SubmitRequest<CollateralMaintenanceRequest, CollateralMaintenanceResponse>(It.IsAny<CollateralMaintenanceRequest>())).Returns(maintenanceResponse).Verifiable();
|
||||
|
||||
var result = _dao.AddCollateralMaintenanceByPropertyNumber(maintenanceRequest);
|
||||
Assert.IsNotNull(result);
|
||||
Assert.IsTrue((bool)result.WasSuccessful);
|
||||
_mockCoreSoapRequest.Verify();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void AddCollateralMaintenanceRequest_Exception()
|
||||
{
|
||||
UserFieldRequest request = new UserFieldRequest()
|
||||
{
|
||||
PropertyNumber = 1,
|
||||
UserFieldCode = "Test",
|
||||
Value = "Test"
|
||||
};
|
||||
|
||||
var maintenanceRequest = CreateCollateralMaintenanceRequest.CreateMaintenanceRequest(request);
|
||||
_mockCoreSoapRequest.Setup(x => x.SubmitRequest<CollateralMaintenanceRequest, CollateralMaintenanceResponse>(maintenanceRequest)).Throws(new Exception("Error thrown in unit test.")).Verifiable();
|
||||
|
||||
Assert.ThrowsException<Exception>(() => _dao.AddCollateralMaintenanceByPropertyNumber(maintenanceRequest));
|
||||
_mockCoreSoapRequest.Verify();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void UpdateCollateralMaintenanceRequest_OK()
|
||||
{
|
||||
UserFieldRequest request = new UserFieldRequest()
|
||||
{
|
||||
PropertyNumber = 1,
|
||||
UserFieldCode = "Test",
|
||||
Value = "Test"
|
||||
};
|
||||
|
||||
var maintenanceRequest = CreateCollateralMaintenanceRequest.CreateMaintenanceRequest(request);
|
||||
var maintenanceResponse = new CollateralMaintenanceResponse
|
||||
{
|
||||
WasSuccessful = true
|
||||
};
|
||||
|
||||
_mockCoreSoapRequest.Setup(x => x.SubmitRequest<CollateralMaintenanceRequest, CollateralMaintenanceResponse>(It.IsAny<CollateralMaintenanceRequest>())).Returns(maintenanceResponse).Verifiable();
|
||||
|
||||
var result = _dao.UpdateCollateralMaintenanceByPropertyNumber(maintenanceRequest);
|
||||
Assert.IsNotNull(result);
|
||||
Assert.IsTrue((bool)result.WasSuccessful);
|
||||
_mockCoreSoapRequest.Verify();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void UpdateCollateralMaintenanceRequest_Exception()
|
||||
{
|
||||
UserFieldRequest request = new UserFieldRequest()
|
||||
{
|
||||
PropertyNumber = 1,
|
||||
UserFieldCode = "Test",
|
||||
Value = "Test"
|
||||
};
|
||||
|
||||
var maintenanceRequest = CreateCollateralMaintenanceRequest.CreateMaintenanceRequest(request);
|
||||
_mockCoreSoapRequest.Setup(x => x.SubmitRequest<CollateralMaintenanceRequest, CollateralMaintenanceResponse>(maintenanceRequest)).Throws(new Exception("Error thrown in unit test.")).Verifiable();
|
||||
|
||||
Assert.ThrowsException<Exception>(() => _dao.UpdateCollateralMaintenanceByPropertyNumber(maintenanceRequest));
|
||||
_mockCoreSoapRequest.Verify();
|
||||
}
|
||||
}
|
||||
}
|
||||
+132
@@ -0,0 +1,132 @@
|
||||
using Moq;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System.Net.Sockets;
|
||||
using System.Collections.Generic;
|
||||
using LCU.API.Internal.CoreSoapApiWrapper.CoreSoapUtilities;
|
||||
using LCU.API.Internal.CoreSoapApiWrapper.DataAccess;
|
||||
using LCU.API.Internal.CoreSoapApiWrapper.Models;
|
||||
using Cmc = LCU.API.Internal.CoreSoapApiWrapper.Models.Cmc;
|
||||
|
||||
|
||||
namespace LCU.API.Internal.CoreSoapApiWrapperTest.DataAccess
|
||||
{
|
||||
[TestClass]
|
||||
public class IndirectLoanDaoTest
|
||||
{
|
||||
private IndirectLoanDao _dao;
|
||||
private Mock<SoapConfiguration> _mockSoapConfiguration;
|
||||
private Mock<ICoreCmcConnection> _mockCoreCmcConnection;
|
||||
|
||||
public IndirectLoanDaoTest()
|
||||
{
|
||||
_mockSoapConfiguration = new Mock<SoapConfiguration>();
|
||||
_mockCoreCmcConnection = new Mock<ICoreCmcConnection>();
|
||||
_mockSoapConfiguration.Object.IPAddress = "10.10.3.26";
|
||||
_mockSoapConfiguration.Object.PortId = 2500;
|
||||
_mockSoapConfiguration.Object.RequestType = "16340";
|
||||
_mockSoapConfiguration.Object.SocketApplicationId = "7726";
|
||||
_mockSoapConfiguration.Object.SocketDeviceId = "FULL";
|
||||
_mockSoapConfiguration.Object.AuthenticationType = "2";
|
||||
_mockSoapConfiguration.Object.SocketTimeout = 10000;
|
||||
|
||||
_dao = new IndirectLoanDao(_mockSoapConfiguration.Object);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void UpdateDealerOriginalBalance_OK()
|
||||
{
|
||||
|
||||
var accountValue = new Cmc.Account()
|
||||
{
|
||||
AcctNbr = "11111111111"
|
||||
};
|
||||
|
||||
var accountRequest = new Cmc.AccountRequest()
|
||||
{
|
||||
Account = accountValue,
|
||||
ReqTypCd = _mockSoapConfiguration.Object.RequestType
|
||||
};
|
||||
|
||||
var userAuthentication = new Cmc.UserAuthentication()
|
||||
{
|
||||
AuthTyp = _mockSoapConfiguration.Object.AuthenticationType,
|
||||
ApplNbr = _mockSoapConfiguration.Object.SocketApplicationId,
|
||||
PhysAddr = _mockSoapConfiguration.Object.SocketDeviceId,
|
||||
UserId = "LOANORIG"
|
||||
//Passwd = "TESTTOKENSTRING" use without token for testing
|
||||
};
|
||||
|
||||
var requestsBase = new List<Cmc.AccountRequest>();
|
||||
requestsBase.Add(accountRequest);
|
||||
|
||||
var input = new Cmc.Input<Cmc.AccountRequest>()
|
||||
{
|
||||
UserAuthentication = userAuthentication,
|
||||
Requests = requestsBase
|
||||
};
|
||||
|
||||
var outputResponse = new Cmc.Response()
|
||||
{
|
||||
SuccessYN = "Y",
|
||||
Errors = new List<Cmc.Error>()
|
||||
};
|
||||
|
||||
var output = new Cmc.Output()
|
||||
{
|
||||
Responses = new List<Cmc.Response>() { outputResponse }
|
||||
};
|
||||
|
||||
var transaction = new Cmc.Transaction<Cmc.AccountRequest>()
|
||||
{
|
||||
Input = input,
|
||||
CommitRollbackYN = "Y",
|
||||
Output = output
|
||||
};
|
||||
_mockCoreCmcConnection.Setup(x => x.CreateSocketTransactionRequest<Cmc.AccountRequest>(It.IsAny<Cmc.AccountRequest>())).Returns(transaction);
|
||||
var result = _dao.UpdateDealerOriginalBalance(transaction);
|
||||
Assert.IsNotNull(result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void UpdateDealerOriginalBalance_Exception()
|
||||
{
|
||||
|
||||
var accountValue = new Cmc.Account()
|
||||
{
|
||||
AcctNbr = "11111111111111"
|
||||
};
|
||||
var accountRequest = new Cmc.AccountRequest()
|
||||
{
|
||||
Account = accountValue,
|
||||
ReqTypCd = _mockSoapConfiguration.Object.RequestType
|
||||
};
|
||||
|
||||
|
||||
var userAuthentication = new Cmc.UserAuthentication()
|
||||
{
|
||||
AuthTyp = _mockSoapConfiguration.Object.AuthenticationType,
|
||||
ApplNbr = _mockSoapConfiguration.Object.SocketApplicationId,
|
||||
PhysAddr = _mockSoapConfiguration.Object.SocketDeviceId,
|
||||
Passwd = "TESTTOKENSTRING"
|
||||
};
|
||||
|
||||
var requestsBase = new List<Cmc.AccountRequest>();
|
||||
|
||||
requestsBase.Add(accountRequest);
|
||||
|
||||
var input = new Cmc.Input<Cmc.AccountRequest>()
|
||||
{
|
||||
UserAuthentication = userAuthentication,
|
||||
Requests = requestsBase
|
||||
};
|
||||
|
||||
var transaction = new Cmc.Transaction<Cmc.AccountRequest>()
|
||||
{
|
||||
//this will cause the socket send to timeout and throw an exception
|
||||
};
|
||||
|
||||
Assert.ThrowsException<SocketException>(() => _dao.UpdateDealerOriginalBalance(transaction));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+182
@@ -0,0 +1,182 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using LCU.API.Internal.CoreSoapApiWrapper.CoreSoapUtilities;
|
||||
using LCU.API.Internal.CoreSoapApiWrapper.DataAccess;
|
||||
|
||||
namespace LCU.API.Internal.CoreSoapApiWrapperTest.DataAccess
|
||||
{
|
||||
[TestClass]
|
||||
public class MonetaryTransactionDaoTest
|
||||
{
|
||||
private MonetaryTransactionDao _dao;
|
||||
private Mock<ICoreSoapRequest> _mockCoreSoapRequest;
|
||||
|
||||
public MonetaryTransactionDaoTest()
|
||||
{
|
||||
_mockCoreSoapRequest = new Mock<ICoreSoapRequest>();
|
||||
_dao = new MonetaryTransactionDao(_mockCoreSoapRequest.Object);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void AddMonetaryTransactions_OK()
|
||||
{
|
||||
var listRequest = new List<MonetaryTransactionRequest>() {
|
||||
|
||||
new MonetaryTransactionRequest()
|
||||
{
|
||||
AccountNumber = 19618756535,
|
||||
RequestNumber = "1",
|
||||
TransactionTypeCode = "DEXP",
|
||||
|
||||
FundBalanceTypes = new FundBalanceType[1]
|
||||
{
|
||||
new FundBalanceType()
|
||||
{
|
||||
FundBalanceAmount = 1.25,
|
||||
FundTypeCode = "EL",
|
||||
FundTypeDetailCode = "IMED"
|
||||
}
|
||||
},
|
||||
|
||||
BalanceTypes = new BalanceType1[1] {
|
||||
new BalanceType1() {
|
||||
BalanceCategoryCode = "UPFR",
|
||||
BalanceTypeCode = "DLR",
|
||||
BalanceTypeAmount = 1.25
|
||||
}
|
||||
},
|
||||
|
||||
Funds = new Fund[1] {
|
||||
new Fund() {
|
||||
ClearingCategoryCode = "IMED",
|
||||
FundAmount = 1.25,
|
||||
FundTypeCode = "EL",
|
||||
FundTypeDetailCode = "INTR",
|
||||
NumberOfItems = 1
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
new MonetaryTransactionRequest()
|
||||
{
|
||||
AccountNumber = 19617805142,
|
||||
TransactionAmount = -1.25,
|
||||
ParentRequestNumber = "1",
|
||||
RequestNumber = "2",
|
||||
TransactionTypeCode = "DRIR",
|
||||
Description = "",
|
||||
|
||||
BalanceTypes = new BalanceType1[1] {
|
||||
new BalanceType1() {
|
||||
BalanceCategoryCode = "UPFR",
|
||||
BalanceTypeCode = "DLR",
|
||||
BalanceTypeAmount = -1.25
|
||||
}
|
||||
},
|
||||
|
||||
Funds = new Fund[1] {
|
||||
new Fund() {
|
||||
ClearingCategoryCode = "IMED",
|
||||
FundAmount = -1.25,
|
||||
FundTypeCode = "EL",
|
||||
FundTypeDetailCode = "INTR",
|
||||
NumberOfItems = 1
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var response = new MonetaryTransactionResponse()
|
||||
{
|
||||
WasSuccessful = true
|
||||
};
|
||||
|
||||
var listResponse = new List<MonetaryTransactionResponse> { response };
|
||||
|
||||
_mockCoreSoapRequest.Setup(x => x.SubmitRequests<MonetaryTransactionRequest, MonetaryTransactionResponse>(listRequest)).Returns(listResponse).Verifiable();
|
||||
|
||||
var result = _dao.AddMonetaryTransactions(listRequest);
|
||||
Assert.IsNotNull(result);
|
||||
Assert.IsTrue((bool)result[0].WasSuccessful);
|
||||
_mockCoreSoapRequest.Verify();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void AddMonetaryTransactions_Exception()
|
||||
{
|
||||
var listRequest = new List<MonetaryTransactionRequest>() {
|
||||
|
||||
new MonetaryTransactionRequest()
|
||||
{
|
||||
AccountNumber = 19618756535,
|
||||
RequestNumber = "1",
|
||||
TransactionTypeCode = "DEXP",
|
||||
|
||||
FundBalanceTypes = new FundBalanceType[1]
|
||||
{
|
||||
new FundBalanceType()
|
||||
{
|
||||
FundBalanceAmount = 1.25,
|
||||
FundTypeCode = "EL",
|
||||
FundTypeDetailCode = "IMED"
|
||||
}
|
||||
},
|
||||
|
||||
BalanceTypes = new BalanceType1[1] {
|
||||
new BalanceType1() {
|
||||
BalanceCategoryCode = "UPFR",
|
||||
BalanceTypeCode = "DLR",
|
||||
BalanceTypeAmount = 1.25
|
||||
}
|
||||
},
|
||||
|
||||
Funds = new Fund[1] {
|
||||
new Fund() {
|
||||
ClearingCategoryCode = "IMED",
|
||||
FundAmount = 1.25,
|
||||
FundTypeCode = "EL",
|
||||
FundTypeDetailCode = "INTR",
|
||||
NumberOfItems = 1
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
new MonetaryTransactionRequest()
|
||||
{
|
||||
AccountNumber = 19617805142,
|
||||
TransactionAmount = -1.25,
|
||||
ParentRequestNumber = "1",
|
||||
RequestNumber = "2",
|
||||
TransactionTypeCode = "DRIR",
|
||||
Description = "",
|
||||
|
||||
BalanceTypes = new BalanceType1[1] {
|
||||
new BalanceType1() {
|
||||
BalanceCategoryCode = "UPFR",
|
||||
BalanceTypeCode = "DLR",
|
||||
BalanceTypeAmount = -1.25
|
||||
}
|
||||
},
|
||||
|
||||
Funds = new Fund[1] {
|
||||
new Fund() {
|
||||
ClearingCategoryCode = "IMED",
|
||||
FundAmount = -1.25,
|
||||
FundTypeCode = "EL",
|
||||
FundTypeDetailCode = "INTR",
|
||||
NumberOfItems = 1
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
_mockCoreSoapRequest.Setup(x => x.SubmitRequests<MonetaryTransactionRequest, MonetaryTransactionResponse>(listRequest)).Throws(new Exception("Error thrown in unit test.")).Verifiable();
|
||||
|
||||
Assert.ThrowsException<Exception>(() => _dao.AddMonetaryTransactions(listRequest));
|
||||
_mockCoreSoapRequest.Verify();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user