Adding
This commit is contained in:
+461
@@ -0,0 +1,461 @@
|
||||
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;
|
||||
using LCU.API.Internal.CoreSoapApiWrapper.Services;
|
||||
using LCU.API.Internal.CoreSoapApiWrapper.Models.Requests;
|
||||
using LCU.API.Internal.CoreSoapApiWrapper.Models.Responses;
|
||||
|
||||
namespace LCU.API.Internal.CoreSoapApiWrapperTest.Services
|
||||
{
|
||||
[TestClass]
|
||||
public class AccountServicesTest
|
||||
{
|
||||
private AccountService _service;
|
||||
private Mock<IAccountDao> _mockAccountDao;
|
||||
|
||||
public AccountServicesTest()
|
||||
{
|
||||
_mockAccountDao = new Mock<IAccountDao>();
|
||||
_service = new AccountService(_mockAccountDao.Object);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetAccountByAccountNumber_OK()
|
||||
{
|
||||
var accountDetailInquiryResponse = new AccountDetailInquiryResponse
|
||||
{
|
||||
WasSuccessful = true
|
||||
};
|
||||
|
||||
_mockAccountDao.Setup(x => x.FindAccountByAccountNumber(1001)).Returns(accountDetailInquiryResponse).Verifiable();
|
||||
|
||||
var result = _service.GetAccountByAccountNumber(1001);
|
||||
Assert.IsNotNull(result);
|
||||
Assert.IsTrue((bool)result.WasSuccessful);
|
||||
_mockAccountDao.Verify();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetAccountByAccountNumber_Exception()
|
||||
{
|
||||
_mockAccountDao.Setup(x => x.FindAccountByAccountNumber(1001)).Throws(new Exception("Error thrown in unit test.")).Verifiable();
|
||||
|
||||
Assert.ThrowsException<Exception>(() => _service.GetAccountByAccountNumber(1001));
|
||||
_mockAccountDao.Verify();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SendAccountMaintenanceRequest_OK()
|
||||
{
|
||||
var maintenanceRequest = new AccountMaintenanceRequest
|
||||
{
|
||||
Accounts = new[]{
|
||||
new MaintenanceAccount
|
||||
{
|
||||
AccountNumber = 123456,
|
||||
DeliveryMethodCode = "PRNT"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var maintenanceResponse = new AccountMaintenanceResponse
|
||||
{
|
||||
WasSuccessful = true
|
||||
};
|
||||
|
||||
_mockAccountDao.Setup(x => x.SendAccountMaintenanceRequest(maintenanceRequest)).Returns(maintenanceResponse).Verifiable();
|
||||
|
||||
var result = _service.SendAccountMaintenanceRequest(maintenanceRequest);
|
||||
Assert.IsNotNull(result);
|
||||
Assert.IsTrue((bool)result.WasSuccessful);
|
||||
_mockAccountDao.Verify();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SendAccountMaintenanceRequest_Exception()
|
||||
{
|
||||
var maintenanceRequest = new AccountMaintenanceRequest
|
||||
{
|
||||
Accounts = new[]{
|
||||
new MaintenanceAccount
|
||||
{
|
||||
AccountNumber = 123456,
|
||||
DeliveryMethodCode = "PRNT"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
_mockAccountDao.Setup(x => x.SendAccountMaintenanceRequest(maintenanceRequest)).Throws(new Exception("Error thrown in unit test.")).Verifiable();
|
||||
|
||||
Assert.ThrowsException<Exception>(() => _service.SendAccountMaintenanceRequest(maintenanceRequest));
|
||||
_mockAccountDao.Verify();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SendAccountGroupAnalysisMaintenanceRequest_OK()
|
||||
{
|
||||
var accountList = new List<AccountAnalysisMaintenance>()
|
||||
{
|
||||
new AccountAnalysisMaintenance()
|
||||
{
|
||||
AccountNumber = 11111111
|
||||
}
|
||||
};
|
||||
|
||||
var accountGroupsList = new List<AccountGroupMaintenance>()
|
||||
{
|
||||
new AccountGroupMaintenance()
|
||||
{
|
||||
AccountGroupNumber = 0,
|
||||
IsGenerateAnalysisStatement = true,
|
||||
IsPrintAnalysisStatement = true,
|
||||
IsUseForServiceCharge = true,
|
||||
ServiceChargeAccountNumber = 11111111,
|
||||
StatementAccountNumber = 11111111,
|
||||
Accounts = accountList.ToArray()
|
||||
}
|
||||
};
|
||||
|
||||
var accountAnalysisMaintenanceRequest = new AccountAnalysisMaintenanceRequest()
|
||||
{
|
||||
AccountGroups = accountGroupsList.ToArray()
|
||||
};
|
||||
|
||||
var accountAnalysisGroupMaintenanceRequest = new AccountAnalysisGroupMaintenanceRequest
|
||||
{
|
||||
AccountNumber = 11111111,
|
||||
IsGenerateAnalysisStatement = true,
|
||||
IsPrintAnalysisStatement = true,
|
||||
IsUseForServiceCharge = true,
|
||||
};
|
||||
|
||||
var maintenanceResponse = new AccountAnalysisMaintenanceResponse
|
||||
{
|
||||
WasSuccessful = true
|
||||
};
|
||||
|
||||
var basicResponse = new BasicResponse(maintenanceResponse);
|
||||
|
||||
_mockAccountDao.Setup(x => x.SendAccountAnalysisMaintenanceRequest(It.IsAny<AccountAnalysisMaintenanceRequest>())).Returns(maintenanceResponse).Verifiable();
|
||||
var result = _service.SendAccountAnalysisGroupMaintenanceRequest(accountAnalysisGroupMaintenanceRequest);
|
||||
Assert.IsNotNull(result);
|
||||
Assert.IsTrue((bool)result.Success);
|
||||
_mockAccountDao.Verify();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SendAccountGroupAnalysisMaintenanceRequest_Exception()
|
||||
{
|
||||
var accountList = new List<AccountAnalysisMaintenance>()
|
||||
{
|
||||
new AccountAnalysisMaintenance()
|
||||
{
|
||||
AccountNumber = 11111111
|
||||
}
|
||||
};
|
||||
|
||||
var accountGroupsList = new List<AccountGroupMaintenance>()
|
||||
{
|
||||
new AccountGroupMaintenance()
|
||||
{
|
||||
AccountGroupNumber = 0,
|
||||
IsGenerateAnalysisStatement = true,
|
||||
IsPrintAnalysisStatement = true,
|
||||
IsUseForServiceCharge = true,
|
||||
ServiceChargeAccountNumber = 11111111,
|
||||
StatementAccountNumber = 11111111,
|
||||
Accounts = accountList.ToArray()
|
||||
}
|
||||
};
|
||||
|
||||
var accountAnalysisMaintenanceRequest = new AccountAnalysisMaintenanceRequest()
|
||||
{
|
||||
AccountGroups = accountGroupsList.ToArray()
|
||||
};
|
||||
|
||||
var accountAnalysisGroupMaintenanceRequest = new AccountAnalysisGroupMaintenanceRequest
|
||||
{
|
||||
AccountNumber = 11111111,
|
||||
IsGenerateAnalysisStatement = true,
|
||||
IsPrintAnalysisStatement = true,
|
||||
IsUseForServiceCharge = true,
|
||||
};
|
||||
|
||||
var maintenanceResponse = new AccountAnalysisMaintenanceResponse
|
||||
{
|
||||
WasSuccessful = false
|
||||
};
|
||||
|
||||
_mockAccountDao.Setup(x => x.SendAccountAnalysisMaintenanceRequest(It.IsAny<AccountAnalysisMaintenanceRequest>())).Throws(new Exception("Error thrown in unit test.")).Verifiable();
|
||||
|
||||
Assert.ThrowsException<Exception>(() => _service.SendAccountAnalysisGroupMaintenanceRequest(accountAnalysisGroupMaintenanceRequest));
|
||||
_mockAccountDao.Verify();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void AddPersonAccount_OK()
|
||||
{
|
||||
var createPersonAccountRequest = new CreatePersonAccountRequest()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
FirstName = "Test",
|
||||
LastName = "Tester",
|
||||
BranchOrganizationNumber = 1
|
||||
};
|
||||
var accountMaintenanceResponse = new AccountMaintenanceResponse()
|
||||
{
|
||||
WasSuccessful = true
|
||||
};
|
||||
var createdAccountResponse = new CreatedAccountResponse(accountMaintenanceResponse);
|
||||
|
||||
_mockAccountDao.Setup(x => x.SendAccountMaintenanceRequest(It.IsAny<AccountMaintenanceRequest>())).Returns(accountMaintenanceResponse).Verifiable();
|
||||
|
||||
var result = _service.AddPersonAccount(createPersonAccountRequest);
|
||||
Assert.IsNotNull(result);
|
||||
Assert.IsTrue((bool)result.BasicResponse.Success);
|
||||
_mockAccountDao.Verify();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void AddPersonAccount_Exception()
|
||||
{
|
||||
var createPersonAccountRequest = new CreatePersonAccountRequest()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
FirstName = "Test",
|
||||
LastName = "Tester",
|
||||
BranchOrganizationNumber = 1
|
||||
};
|
||||
var accountMaintenanceResponse = new AccountMaintenanceResponse()
|
||||
{
|
||||
WasSuccessful = false
|
||||
};
|
||||
var createdAccountResponse = new CreatedAccountResponse(accountMaintenanceResponse);
|
||||
|
||||
_mockAccountDao.Setup(x => x.SendAccountMaintenanceRequest(It.IsAny<AccountMaintenanceRequest>())).Throws(new Exception("Error thrown in unit test.")).Verifiable();
|
||||
|
||||
Assert.ThrowsException<Exception>(() => _service.AddPersonAccount(createPersonAccountRequest));
|
||||
_mockAccountDao.Verify();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void AddOrganizationAccount_OK()
|
||||
{
|
||||
var createOrganizationAccountRequest = new CreateOrganizationAccountRequest()
|
||||
{
|
||||
OrganizationNumber = 1,
|
||||
BranchOrganizationNumber = 1
|
||||
};
|
||||
var accountMaintenanceResponse = new AccountMaintenanceResponse()
|
||||
{
|
||||
WasSuccessful = true
|
||||
};
|
||||
var createdAccountResponse = new CreatedAccountResponse(accountMaintenanceResponse);
|
||||
|
||||
_mockAccountDao.Setup(x => x.SendAccountMaintenanceRequest(It.IsAny<AccountMaintenanceRequest>())).Returns(accountMaintenanceResponse).Verifiable();
|
||||
|
||||
var result = _service.AddOrganizationAccount(createOrganizationAccountRequest);
|
||||
Assert.IsNotNull(result);
|
||||
Assert.IsTrue((bool)result.BasicResponse.Success);
|
||||
_mockAccountDao.Verify();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void AddOrganizationAccount_Exception()
|
||||
{
|
||||
var createOrganizationAccountRequest = new CreateOrganizationAccountRequest()
|
||||
{
|
||||
OrganizationNumber = 1,
|
||||
BranchOrganizationNumber = 1
|
||||
};
|
||||
var accountMaintenanceResponse = new AccountMaintenanceResponse()
|
||||
{
|
||||
WasSuccessful = false
|
||||
};
|
||||
var createdAccountResponse = new CreatedAccountResponse(accountMaintenanceResponse);
|
||||
|
||||
_mockAccountDao.Setup(x => x.SendAccountMaintenanceRequest(It.IsAny<AccountMaintenanceRequest>())).Throws(new Exception("Error thrown in unit test.")).Verifiable();
|
||||
|
||||
Assert.ThrowsException<Exception>(() => _service.AddOrganizationAccount(createOrganizationAccountRequest));
|
||||
_mockAccountDao.Verify();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void AddOrganizationControllerPerson_OK()
|
||||
{
|
||||
var orgMaintenanceRequest = new OrganizationMaintenanceRequest()
|
||||
{
|
||||
OrganizationNumber = 1,
|
||||
ControllingPersonNumber = 1
|
||||
};
|
||||
var orgMaintenanceResponse = new OrgMaintenanceResponse()
|
||||
{
|
||||
WasSuccessful = true
|
||||
};
|
||||
|
||||
_mockAccountDao.Setup(x => x.SendOrgMaintenanceRequest(It.IsAny<OrgMaintenanceRequest>())).Returns(orgMaintenanceResponse).Verifiable();
|
||||
|
||||
var result = _service.AddOrganizationControlPerson(orgMaintenanceRequest);
|
||||
Assert.IsNotNull(result);
|
||||
Assert.IsTrue((bool)result.Success);
|
||||
_mockAccountDao.Verify();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void AddOrganizationControllerPerson_Exception()
|
||||
{
|
||||
var orgMaintenanceRequest = new OrganizationMaintenanceRequest()
|
||||
{
|
||||
OrganizationNumber = 1,
|
||||
ControllingPersonNumber = 1
|
||||
};
|
||||
var orgMaintenanceResponse = new OrgMaintenanceResponse()
|
||||
{
|
||||
WasSuccessful = false
|
||||
};
|
||||
|
||||
_mockAccountDao.Setup(x => x.SendOrgMaintenanceRequest(It.IsAny<OrgMaintenanceRequest>())).Throws(new Exception("Error thrown in unit test.")).Verifiable();
|
||||
|
||||
Assert.ThrowsException<Exception>(() => _service.AddOrganizationControlPerson(orgMaintenanceRequest));
|
||||
_mockAccountDao.Verify();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SendAccountNickNameUpdateRequest_OK()
|
||||
{
|
||||
var accountRequest = new AccountNickNameUpdateRequest()
|
||||
{
|
||||
AccountNumber = 1111111,
|
||||
AccountDescription = "TestSuccess"
|
||||
};
|
||||
|
||||
var maintenanceResponse = new AccountMaintenanceResponse
|
||||
{
|
||||
WasSuccessful = true
|
||||
};
|
||||
|
||||
var basicResponse = new BasicResponse(maintenanceResponse);
|
||||
|
||||
_mockAccountDao.Setup(x => x.SendAccountMaintenanceRequest(It.IsAny<AccountMaintenanceRequest>())).Returns(maintenanceResponse).Verifiable();
|
||||
var result = _service.SendAccountNickNameUpdateRequest(accountRequest);
|
||||
Assert.IsNotNull(result);
|
||||
Assert.IsTrue((bool)result.Success);
|
||||
_mockAccountDao.Verify();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SendAccountNickNameUpdateRequest_Exception()
|
||||
{
|
||||
var accountRequest = new AccountNickNameUpdateRequest()
|
||||
{
|
||||
AccountNumber = 1111111,
|
||||
AccountDescription = "TestException"
|
||||
};
|
||||
|
||||
var maintenanceResponse = new AccountMaintenanceResponse
|
||||
{
|
||||
WasSuccessful = false
|
||||
};
|
||||
|
||||
var basicResponse = new BasicResponse(maintenanceResponse);
|
||||
|
||||
_mockAccountDao.Setup(x => x.SendAccountMaintenanceRequest(It.IsAny<AccountMaintenanceRequest>())).Throws(new Exception("Error thrown in unit test.")).Verifiable();
|
||||
|
||||
Assert.ThrowsException<Exception>(() => _service.SendAccountNickNameUpdateRequest(accountRequest));
|
||||
_mockAccountDao.Verify();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SendAccountCreditReportTypeUpdateRequest_OK()
|
||||
{
|
||||
var accountRequest = new AccountCreditReportTypeUpdateRequest()
|
||||
{
|
||||
AccountNumber = 1111111,
|
||||
CreditReportType = "EXCL"
|
||||
};
|
||||
|
||||
var maintenanceResponse = new AccountMaintenanceResponse
|
||||
{
|
||||
WasSuccessful = true
|
||||
};
|
||||
|
||||
var basicResponse = new BasicResponse(maintenanceResponse);
|
||||
|
||||
_mockAccountDao.Setup(x => x.SendAccountMaintenanceRequest(It.IsAny<AccountMaintenanceRequest>())).Returns(maintenanceResponse).Verifiable();
|
||||
var result = _service.SendAccountCreditReportTypeUpdateRequest(accountRequest);
|
||||
Assert.IsNotNull(result);
|
||||
Assert.IsTrue((bool)result.Success);
|
||||
_mockAccountDao.Verify();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SendAccountCreditReportTypeUpdateRequest_Exception()
|
||||
{
|
||||
var accountRequest = new AccountCreditReportTypeUpdateRequest()
|
||||
{
|
||||
AccountNumber = 1111111,
|
||||
CreditReportType = "EXCL"
|
||||
};
|
||||
|
||||
var maintenanceResponse = new AccountMaintenanceResponse
|
||||
{
|
||||
WasSuccessful = false
|
||||
};
|
||||
|
||||
var basicResponse = new BasicResponse(maintenanceResponse);
|
||||
|
||||
_mockAccountDao.Setup(x => x.SendAccountMaintenanceRequest(It.IsAny<AccountMaintenanceRequest>())).Throws(new Exception("Error thrown in unit test.")).Verifiable();
|
||||
|
||||
Assert.ThrowsException<Exception>(() => _service.SendAccountCreditReportTypeUpdateRequest(accountRequest));
|
||||
_mockAccountDao.Verify();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SendAccountContractDateUpdateRequest_OK()
|
||||
{
|
||||
var accountRequest = new AccountContractDateUpdateRequest()
|
||||
{
|
||||
AccountNumber = 1111111,
|
||||
ContractDate = DateTime.Now,
|
||||
};
|
||||
|
||||
var maintenanceResponse = new AccountMaintenanceResponse
|
||||
{
|
||||
WasSuccessful = true
|
||||
};
|
||||
|
||||
var basicResponse = new BasicResponse(maintenanceResponse);
|
||||
|
||||
_mockAccountDao.Setup(x => x.SendAccountMaintenanceRequest(It.IsAny<AccountMaintenanceRequest>())).Returns(maintenanceResponse).Verifiable();
|
||||
var result = _service.SendAccountContractDateUpdateRequest(accountRequest);
|
||||
Assert.IsNotNull(result);
|
||||
Assert.IsTrue((bool)result.Success);
|
||||
_mockAccountDao.Verify();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SendAccountContractDateUpdateRequest_Exception()
|
||||
{
|
||||
var accountRequest = new AccountContractDateUpdateRequest()
|
||||
{
|
||||
AccountNumber = 1111111,
|
||||
ContractDate = DateTime.Now,
|
||||
};
|
||||
|
||||
var maintenanceResponse = new AccountMaintenanceResponse
|
||||
{
|
||||
WasSuccessful = false
|
||||
};
|
||||
|
||||
var basicResponse = new BasicResponse(maintenanceResponse);
|
||||
|
||||
_mockAccountDao.Setup(x => x.SendAccountMaintenanceRequest(It.IsAny<AccountMaintenanceRequest>())).Throws(new Exception("Error thrown in unit test.")).Verifiable();
|
||||
|
||||
Assert.ThrowsException<Exception>(() => _service.SendAccountContractDateUpdateRequest(accountRequest));
|
||||
_mockAccountDao.Verify();
|
||||
}
|
||||
}
|
||||
}
|
||||
+126
@@ -0,0 +1,126 @@
|
||||
using LCU.API.Internal.CoreSoapApiWrapper.CoreSoapUtilities;
|
||||
using LCU.API.Internal.CoreSoapApiWrapper.DataAccess;
|
||||
using LCU.API.Internal.CoreSoapApiWrapper.Models.Requests;
|
||||
using LCU.API.Internal.CoreSoapApiWrapper.Services;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using System;
|
||||
|
||||
namespace LCU.API.Internal.CoreSoapApiWrapperTest.Services
|
||||
{
|
||||
[TestClass]
|
||||
public class CollateralMaintenanceServiceTest
|
||||
{
|
||||
private CollateralMaintenanceService _service;
|
||||
private Mock<ICollateralMaintenanceDao> _mockCollateralDao;
|
||||
|
||||
public CollateralMaintenanceServiceTest()
|
||||
{
|
||||
_mockCollateralDao = new Mock<ICollateralMaintenanceDao>();
|
||||
_service = new CollateralMaintenanceService(_mockCollateralDao.Object);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetPropertyByPropertyNumber_OK()
|
||||
{
|
||||
var searchResponse = new CollateralSearchResponse
|
||||
{
|
||||
WasSuccessful = true
|
||||
};
|
||||
|
||||
_mockCollateralDao.Setup(x => x.FindCollateralMaintenanceByPropertyNumber(100000)).Returns(searchResponse).Verifiable();
|
||||
|
||||
var result = _service.GetCollateralMaintenanceByPropertyNumber(100000);
|
||||
Assert.IsNotNull(result);
|
||||
Assert.IsTrue((bool)result.WasSuccessful);
|
||||
_mockCollateralDao.Verify();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetPropertyByPropertyNumber_Exception()
|
||||
{
|
||||
_mockCollateralDao.Setup(x => x.FindCollateralMaintenanceByPropertyNumber(100000)).Throws(new Exception("Error thrown in unit test.")).Verifiable();
|
||||
|
||||
Assert.ThrowsException<Exception>(() => _service.GetCollateralMaintenanceByPropertyNumber(100000));
|
||||
_mockCollateralDao.Verify();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void PostCollateralMaintenanceRequest_OK()
|
||||
{
|
||||
var fieldDetails = new UserFieldRequest()
|
||||
{
|
||||
PropertyNumber = 100000,
|
||||
UserFieldCode = "TEST",
|
||||
Value = "TEST"
|
||||
};
|
||||
|
||||
var maintenanceResponse = new CollateralMaintenanceResponse()
|
||||
{
|
||||
WasSuccessful = true
|
||||
};
|
||||
|
||||
_mockCollateralDao.Setup(x => x.AddCollateralMaintenanceByPropertyNumber(It.IsAny<CollateralMaintenanceRequest>())).Returns(maintenanceResponse).Verifiable();
|
||||
|
||||
var result = _service.InsertCollateralMaintenance(fieldDetails);
|
||||
Assert.IsNotNull(result);
|
||||
Assert.IsTrue((bool)result.Success);
|
||||
_mockCollateralDao.Verify();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void PostCollateralMaintenanceRequest_Exception()
|
||||
{
|
||||
var fieldDetails = new UserFieldRequest()
|
||||
{
|
||||
PropertyNumber = 100000,
|
||||
UserFieldCode = "TEST",
|
||||
Value = "TEST"
|
||||
};
|
||||
|
||||
_mockCollateralDao.Setup(x => x.AddCollateralMaintenanceByPropertyNumber(It.IsAny<CollateralMaintenanceRequest>())).Throws(new Exception("Error thrown in unit test.")).Verifiable();
|
||||
|
||||
Assert.ThrowsException<Exception>(() => _service.InsertCollateralMaintenance(fieldDetails));
|
||||
_mockCollateralDao.Verify();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void PutCollateralMaintenanceRequest_OK()
|
||||
{
|
||||
var fieldDetails = new UserFieldRequest()
|
||||
{
|
||||
PropertyNumber = 100000,
|
||||
UserFieldCode = "TEST",
|
||||
Value = "TEST"
|
||||
};
|
||||
|
||||
var maintenanceResponse = new CollateralMaintenanceResponse()
|
||||
{
|
||||
WasSuccessful = true
|
||||
};
|
||||
|
||||
_mockCollateralDao.Setup(x => x.UpdateCollateralMaintenanceByPropertyNumber(It.IsAny<CollateralMaintenanceRequest>())).Returns(maintenanceResponse).Verifiable();
|
||||
|
||||
var result = _service.UpdateCollateralMaintenance(fieldDetails);
|
||||
Assert.IsNotNull(result);
|
||||
Assert.IsTrue((bool)result.Success);
|
||||
_mockCollateralDao.Verify();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void PutCollateralMaintenanceRequest_Exception()
|
||||
{
|
||||
var fieldDetails = new UserFieldRequest()
|
||||
{
|
||||
PropertyNumber = 100000,
|
||||
UserFieldCode = "TEST",
|
||||
Value = "TEST"
|
||||
};
|
||||
|
||||
_mockCollateralDao.Setup(x => x.UpdateCollateralMaintenanceByPropertyNumber(It.IsAny<CollateralMaintenanceRequest>())).Throws(new Exception("Error thrown in unit test.")).Verifiable();
|
||||
|
||||
Assert.ThrowsException<Exception>(() => _service.UpdateCollateralMaintenance(fieldDetails));
|
||||
_mockCollateralDao.Verify();
|
||||
}
|
||||
}
|
||||
}
|
||||
+161
@@ -0,0 +1,161 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using LCU.API.Internal.CoreSoapApiWrapper.DataAccess;
|
||||
using LCU.API.Internal.CoreSoapApiWrapper.Models;
|
||||
using LCU.API.Internal.CoreSoapApiWrapper.Services;
|
||||
using LCU.API.Internal.CoreSoapApiWrapper.CoreSoapUtilities;
|
||||
using LCU.API.Internal.CoreSoapApiWrapper.Models.Response;
|
||||
using Cmc = LCU.API.Internal.CoreSoapApiWrapper.Models.Cmc;
|
||||
|
||||
namespace LCU.API.Internal.CoreSoapApiWrapperTest.Services
|
||||
{
|
||||
[TestClass]
|
||||
public class IndirectLoanServiceTest
|
||||
{
|
||||
private IndirectLoanService _service;
|
||||
private Mock<IIndirectLoanDao> _mockDao;
|
||||
private Mock<SoapConfiguration> _mockSoapConfiguration;
|
||||
private Mock<ICoreCmcConnection> _mockCoreCmcConnection;
|
||||
private const string AuthTypeToken = "3";
|
||||
|
||||
public IndirectLoanServiceTest()
|
||||
{
|
||||
_mockDao = new Mock<IIndirectLoanDao>();
|
||||
_mockSoapConfiguration = new Mock<SoapConfiguration>();
|
||||
_mockCoreCmcConnection = new Mock<ICoreCmcConnection>();
|
||||
|
||||
_mockSoapConfiguration.Object.RequestType = "16370";
|
||||
_mockSoapConfiguration.Object.IPAddress = "10.10.0.00";
|
||||
_mockSoapConfiguration.Object.PortId = 2500;
|
||||
_mockSoapConfiguration.Object.RequestType = "16340";
|
||||
_mockSoapConfiguration.Object.SocketApplicationId = "7726";
|
||||
_mockSoapConfiguration.Object.SocketDeviceId = "FULL";
|
||||
_mockSoapConfiguration.Object.AuthenticationType = "2";
|
||||
_mockSoapConfiguration.Object.SocketTimeout = 10000;
|
||||
|
||||
_service = new IndirectLoanService(_mockDao.Object, _mockCoreCmcConnection.Object, _mockSoapConfiguration.Object);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void UpdateDealerOriginalBalancesRequest_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
|
||||
};
|
||||
|
||||
var account = "11111111111";
|
||||
|
||||
var response = new UpdateDealerOriginalBalanceResponse();
|
||||
_mockCoreCmcConnection.Setup(x => x.CreateSocketTransactionRequest<Cmc.AccountRequest>(It.IsAny<Cmc.AccountRequest>())).Returns(transaction);
|
||||
_mockDao.Setup(x => x.UpdateDealerOriginalBalance<Cmc.AccountRequest>(transaction)).Returns(transaction).Verifiable();
|
||||
|
||||
var result = _service.UpdateDealerOriginalBalances(account);
|
||||
Assert.IsNotNull(result);
|
||||
_mockCoreCmcConnection.Verify();
|
||||
_mockDao.Verify();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void UpdateDealerOriginalBalancesRequest_Exception()
|
||||
{
|
||||
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
|
||||
};
|
||||
|
||||
var account = "11111111111111";
|
||||
_mockCoreCmcConnection.Setup(x => x.CreateSocketTransactionRequest<Cmc.AccountRequest>(It.IsAny<Cmc.AccountRequest>())).Returns(transaction);
|
||||
_mockDao.Setup(x => x.UpdateDealerOriginalBalance<Cmc.AccountRequest>(transaction)).Throws(new Exception("Error thrown in unit test.")).Verifiable();
|
||||
|
||||
Assert.ThrowsException<Exception>(() => _service.UpdateDealerOriginalBalances(account));
|
||||
_mockDao.Verify();
|
||||
}
|
||||
}
|
||||
}
|
||||
+208
@@ -0,0 +1,208 @@
|
||||
using LCU.API.Internal.CoreSoapApiWrapper.CoreSoapUtilities;
|
||||
using LCU.API.Internal.CoreSoapApiWrapper.DataAccess;
|
||||
using LCU.API.Internal.CoreSoapApiWrapper.Models;
|
||||
using LCU.API.Internal.CoreSoapApiWrapper.Models.Requests;
|
||||
using LCU.API.Internal.CoreSoapApiWrapper.Services;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace LCU.API.Internal.CoreSoapApiWrapperTest.Services
|
||||
{
|
||||
[TestClass]
|
||||
public class MonetaryTranscationServiceTest
|
||||
{
|
||||
private MonetaryTransactionService _service;
|
||||
private Mock<IMonetaryTransactionDao> _mockDao;
|
||||
private Mock<SoapConfiguration> _mockSoapConfiguration;
|
||||
|
||||
public MonetaryTranscationServiceTest()
|
||||
{
|
||||
_mockDao = new Mock<IMonetaryTransactionDao>();
|
||||
_mockSoapConfiguration = new Mock<SoapConfiguration>();
|
||||
|
||||
_mockSoapConfiguration.Object.ApprovalPersonNumber = "5225";
|
||||
_mockSoapConfiguration.Object.OverrideCashBoxNumber = "800";
|
||||
|
||||
_service = new MonetaryTransactionService(_mockDao.Object, _mockSoapConfiguration.Object);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void AddMonetaryTransactionsRequest_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 = true
|
||||
};
|
||||
|
||||
var listResponse = new List<MonetaryTransactionResponse> { response };
|
||||
var listGroupRequest = new List<GroupedMonetaryTransactionRequest> { groupRequest };
|
||||
|
||||
_mockDao.Setup(x => x.AddMonetaryTransactions(groupRequest.MonetaryTransactionRequests)).Returns(listResponse).Verifiable();
|
||||
|
||||
var result = _service.AddMonetaryTransactions(listGroupRequest);
|
||||
Assert.IsNotNull(result);
|
||||
|
||||
_mockDao.Verify();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void AddMonetaryTransactionsRequest_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 };
|
||||
|
||||
_mockDao.Setup(x => x.AddMonetaryTransactions(groupRequest.MonetaryTransactionRequests)).Throws(new Exception("Error thrown in unit test.")).Verifiable();
|
||||
Assert.ThrowsException<Exception>(() => _service.AddMonetaryTransactions(listGroupRequest));
|
||||
_mockDao.Verify();
|
||||
}
|
||||
}
|
||||
}
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using LCU.API.Internal.CoreSoapApiWrapper.CoreSoapUtilities;
|
||||
using LCU.API.Internal.CoreSoapApiWrapper.DataAccess;
|
||||
using LCU.API.Internal.CoreSoapApiWrapper.Models.Requests;
|
||||
using LCU.API.Internal.CoreSoapApiWrapper.Services;
|
||||
|
||||
namespace LCU.API.Internal.CoreSoapApiWrapperTest.Services
|
||||
{
|
||||
[TestClass]
|
||||
public class PersonAgreementServiceTest
|
||||
{
|
||||
private PersonAgreementService _service;
|
||||
private Mock<IPersonAgreementDao> _mockPersonAgreementDao;
|
||||
|
||||
public PersonAgreementServiceTest()
|
||||
{
|
||||
_mockPersonAgreementDao = new Mock<IPersonAgreementDao>();
|
||||
_service = new PersonAgreementService(_mockPersonAgreementDao.Object);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void UpdatePersonAgreementsDetailTypes_OK()
|
||||
{
|
||||
var response = new PersonAgreementMaintenanceResponse()
|
||||
{
|
||||
WasSuccessful = true
|
||||
};
|
||||
|
||||
_mockPersonAgreementDao.Setup(x => x.SendPersonAgreementMaintenanceRequest(It.IsAny<PersonAgreementMaintenanceRequest>()))
|
||||
.Returns(response).Verifiable();
|
||||
|
||||
var request = new PersonAgreementDetailTypeRequest()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
AgreeNumber = 2,
|
||||
DetailTypes = new List<DetailType>()
|
||||
{
|
||||
new DetailType()
|
||||
{
|
||||
DetailTypeCode = "Stat",
|
||||
DetailValue = "CLOS"
|
||||
}
|
||||
}
|
||||
};
|
||||
var result = _service.UpdatePersonAgreementsDetailTypes(request);
|
||||
Assert.IsNotNull(result);
|
||||
Assert.IsTrue((bool)result.Success);
|
||||
_mockPersonAgreementDao.Verify();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void UpdatePersonAgreementsDetailTypes_Exception()
|
||||
{
|
||||
_mockPersonAgreementDao.Setup(x => x.SendPersonAgreementMaintenanceRequest(It.IsAny<PersonAgreementMaintenanceRequest>()))
|
||||
.Throws(new Exception("Error thrown in unit test.")).Verifiable();
|
||||
|
||||
var request = new PersonAgreementDetailTypeRequest()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
AgreeNumber = 2,
|
||||
DetailTypes = new List<DetailType>()
|
||||
{
|
||||
new DetailType()
|
||||
{
|
||||
DetailTypeCode = "Stat",
|
||||
DetailValue = "CLOS"
|
||||
}
|
||||
}
|
||||
};
|
||||
Assert.ThrowsException<Exception>(() => _service.UpdatePersonAgreementsDetailTypes(request));
|
||||
_mockPersonAgreementDao.Verify();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void UpdatePersonAgreementsDetailTypes_DetailTypes_Null_Exception()
|
||||
{
|
||||
var request = new PersonAgreementDetailTypeRequest()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
AgreeNumber = 2,
|
||||
DetailTypes = null
|
||||
};
|
||||
Assert.ThrowsException<ArgumentNullException>(() => _service.UpdatePersonAgreementsDetailTypes(request));
|
||||
_mockPersonAgreementDao.Verify(x => x.SendPersonAgreementMaintenanceRequest(
|
||||
It.IsAny<PersonAgreementMaintenanceRequest>()), Times.Never);
|
||||
}
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
using LCU.API.Internal.CoreSoapApiWrapper.CoreSoapUtilities;
|
||||
using LCU.API.Internal.CoreSoapApiWrapper.DataAccess;
|
||||
using LCU.API.Internal.CoreSoapApiWrapper.Services;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using System;
|
||||
|
||||
namespace LCU.API.Internal.CoreSoapApiWrapperTest.Services
|
||||
{
|
||||
[TestClass]
|
||||
public class TaxServicesTest
|
||||
{
|
||||
private readonly TaxService _service;
|
||||
private readonly Mock<ITaxDao> _mockTaxDao;
|
||||
|
||||
public TaxServicesTest()
|
||||
{
|
||||
_mockTaxDao = new Mock<ITaxDao>();
|
||||
_service = new TaxService(_mockTaxDao.Object);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetTaxIdData_OK()
|
||||
{
|
||||
var taxIdResponse = new GetTaxIdDataResponse
|
||||
{
|
||||
WasSuccessful = true
|
||||
};
|
||||
|
||||
_mockTaxDao.Setup(x => x.GetTaxIdData(1001)).Returns(taxIdResponse).Verifiable();
|
||||
|
||||
var result = _service.GetTaxIdData(1001);
|
||||
Assert.IsNotNull(result);
|
||||
Assert.IsTrue((bool)result.WasSuccessful);
|
||||
_mockTaxDao.Verify();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetTaxIdData_Exception()
|
||||
{
|
||||
_mockTaxDao.Setup(x => x.GetTaxIdData(1001)).Throws(new Exception("Error thrown in unit test.")).Verifiable();
|
||||
|
||||
Assert.ThrowsException<Exception>(() => _service.GetTaxIdData(1001));
|
||||
_mockTaxDao.Verify();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user