210 lines
8.7 KiB
C#
210 lines
8.7 KiB
C#
using LCU.API.Internal.CoreSoapApiWrapper.Controllers;
|
|
using LCU.API.Internal.CoreSoapApiWrapper.CoreSoapUtilities;
|
|
using LCU.API.Internal.CoreSoapApiWrapper.Services;
|
|
using LCU.API.Internal.CoreSoapApiWrapper.Models.Requests;
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
using Moq;
|
|
using System;
|
|
using System.Web.Http.Results;
|
|
using System.Collections.Generic;
|
|
|
|
namespace LCU.API.Internal.CoreSoapApiWrapperTest.Controllers
|
|
{
|
|
[TestClass]
|
|
public class MonetaryTransactionControllerTest
|
|
{
|
|
private MonetaryTransactionController _controller;
|
|
private Mock<IMonetaryTransactionService> _mockMonetaryTransactionService;
|
|
|
|
public MonetaryTransactionControllerTest()
|
|
{
|
|
_mockMonetaryTransactionService = new Mock<IMonetaryTransactionService>();
|
|
_controller = new MonetaryTransactionController(_mockMonetaryTransactionService.Object);
|
|
}
|
|
|
|
[TestMethod]
|
|
public void PostMonetaryTransactionsRequest_OK()
|
|
{
|
|
|
|
var groupRequest = new GroupedMonetaryTransactionRequest()
|
|
{
|
|
|
|
MonetaryTransactionRequests = 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 = false
|
|
};
|
|
|
|
var listResponse = new List<MonetaryTransactionResponse> { response };
|
|
var listGroupRequest = new List<GroupedMonetaryTransactionRequest> { groupRequest };
|
|
|
|
_mockMonetaryTransactionService.Setup(x => x.AddMonetaryTransactions(listGroupRequest)).Returns(listResponse).Verifiable();
|
|
|
|
var result = _controller.PostMonetaryTransactions(listGroupRequest);
|
|
Assert.IsNotNull(result);
|
|
|
|
var okResult = result as OkNegotiatedContentResult<List<MonetaryTransactionResponse>>;
|
|
Assert.IsNotNull(okResult);
|
|
_mockMonetaryTransactionService.Verify();
|
|
}
|
|
|
|
[TestMethod]
|
|
public void PostMonetaryTransactionsRequest_Exception()
|
|
{
|
|
|
|
var groupRequest = new GroupedMonetaryTransactionRequest()
|
|
{
|
|
|
|
MonetaryTransactionRequests = 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 = false
|
|
};
|
|
|
|
var listResponse = new List<MonetaryTransactionResponse> { response };
|
|
var listGroupRequest = new List<GroupedMonetaryTransactionRequest> { groupRequest };
|
|
|
|
_mockMonetaryTransactionService.Setup(x => x.AddMonetaryTransactions(listGroupRequest)).Throws(new Exception("Error thrown in unit test.")).Verifiable();
|
|
|
|
var result = _controller.PostMonetaryTransactions(listGroupRequest);
|
|
Assert.IsNotNull(result);
|
|
var badResult = result as BadRequestErrorMessageResult;
|
|
Assert.IsNotNull(badResult);
|
|
_mockMonetaryTransactionService.Verify();
|
|
}
|
|
}
|
|
} |