132 lines
4.6 KiB
C#
132 lines
4.6 KiB
C#
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));
|
|
}
|
|
|
|
}
|
|
} |