182 lines
6.5 KiB
C#
182 lines
6.5 KiB
C#
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();
|
|
}
|
|
|
|
}
|
|
} |