744 lines
26 KiB
C#
744 lines
26 KiB
C#
using System;
|
|
using System.Linq;
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using NUnit.Framework;
|
|
using Moq;
|
|
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels;
|
|
using LCU.Library.Internal.CoreApiWrapperLib.DataAccess;
|
|
using LCU.Library.Internal.CoreApiWrapperLib.Exceptions;
|
|
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Accounts;
|
|
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreRequests;
|
|
using LCU.Library.Internal.Exceptions;
|
|
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreResponses;
|
|
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreSoapResponses;
|
|
using LCU.Api.Internal.CoreApiWrapper.Services;
|
|
|
|
namespace LCU.Api.Internal.CoreApiWrapperTest.Service
|
|
{
|
|
public class AccountServiceTest
|
|
{
|
|
private readonly AccountService _accountService;
|
|
private readonly Mock<IAccountDao> _mockAccountDao;
|
|
|
|
public AccountServiceTest()
|
|
{
|
|
_mockAccountDao = new Mock<IAccountDao>();
|
|
_accountService = new AccountService(_mockAccountDao.Object);
|
|
}
|
|
|
|
[Test]
|
|
public async Task GetAccountDetailsByAccountNumber_Returns_AccountDetails()
|
|
{
|
|
var testAccount = new Account()
|
|
{
|
|
Id = "fasd;fljqer8-3418-3824-8dsfjas;djf",
|
|
ContractDate = "1/1/2021"
|
|
};
|
|
_mockAccountDao.Setup(x => x.FindByAcctNbr(It.IsAny<CoreRequestParameters>(), It.IsAny<AcctNbrRequest>())).ReturnsAsync(testAccount);
|
|
var testAccountNumber = 1000143;
|
|
var result = await _accountService.GetAccountDetailsByAccountNumber(testAccountNumber);
|
|
|
|
Assert.NotNull(result);
|
|
Assert.AreEqual("fasd;fljqer8-3418-3824-8dsfjas;djf", result.Id);
|
|
Assert.AreEqual("1/1/2021", result.ContractDate);
|
|
}
|
|
|
|
[Test]
|
|
public async Task PutAccountMaintenanceRequest_UpdateSuccessful()
|
|
{
|
|
var accountMaintenanceRequest = new List<AccountMaintenanceRequest>
|
|
{
|
|
new() {
|
|
AccountNumber = 123,
|
|
DeliveryMethod = "PRNT"
|
|
}
|
|
};
|
|
|
|
await _accountService.PutAccountMaintenanceRequest(accountMaintenanceRequest);
|
|
_mockAccountDao.Verify(x => x.PutAccountMaintenanceRequest(accountMaintenanceRequest), Times.Once);
|
|
}
|
|
|
|
[Test]
|
|
public void PutAccountMaintenanceRequest_ExceptionThrown()
|
|
{
|
|
var accountMaintenanceRequest = new List<AccountMaintenanceRequest>
|
|
{
|
|
new() {
|
|
AccountNumber = 123,
|
|
DeliveryMethod = "PRNT"
|
|
}
|
|
};
|
|
|
|
_mockAccountDao.Setup(x => x.PutAccountMaintenanceRequest(accountMaintenanceRequest)).ThrowsAsync(new AccountMaintenanceRequestException("Test exception"));
|
|
|
|
Assert.ThrowsAsync<AccountMaintenanceRequestException>(async () => await _accountService.PutAccountMaintenanceRequest(accountMaintenanceRequest));
|
|
}
|
|
|
|
[Test]
|
|
public async Task GetActivityAccountDetailsByAccountNumbers_OK()
|
|
{
|
|
_mockAccountDao.Setup(x => x.GetActivityAccountDetailsByAccountNumbers(It.IsAny<List<string>>()))
|
|
.ReturnsAsync(new List<ActivityAccountDetails>()
|
|
{
|
|
new ActivityAccountDetails()
|
|
{
|
|
AccountNumber = 12345,
|
|
MinorAccountType = "DV01",
|
|
CurrentAccountStatus = "ACT"
|
|
},
|
|
new ActivityAccountDetails()
|
|
{
|
|
AccountNumber = 6789,
|
|
MinorAccountType = "DV01",
|
|
CurrentAccountStatus = "ACT"
|
|
}
|
|
});
|
|
|
|
var results =
|
|
await _accountService.GetActivityAccountDetailsByAccountNumbers(new List<long>() { 12345, 6789 });
|
|
Assert.NotNull(results);
|
|
Assert.AreEqual(2, results.Count);
|
|
_mockAccountDao.Verify(x =>
|
|
x.GetActivityAccountDetailsByAccountNumbers(It.Is<List<string>>(x =>
|
|
x.Contains("12345") && x.Contains("6789"))));
|
|
}
|
|
|
|
[Test]
|
|
public async Task GetActivityAccountDetailsByAccountNumbers_NoSearch_OK()
|
|
{
|
|
_mockAccountDao.Setup(x => x.GetActivityAccountDetailsByAccountNumbers(It.IsAny<List<string>>()))
|
|
.ReturnsAsync(new List<ActivityAccountDetails>()
|
|
{
|
|
new()
|
|
{
|
|
AccountNumber = 12345,
|
|
MinorAccountType = "DV01",
|
|
CurrentAccountStatus = "ACT"
|
|
},
|
|
new()
|
|
{
|
|
AccountNumber = 6789,
|
|
MinorAccountType = "DV01",
|
|
CurrentAccountStatus = "ACT"
|
|
}
|
|
});
|
|
|
|
var results = await _accountService.GetActivityAccountDetailsByAccountNumbers(new List<long>() { });
|
|
Assert.NotNull(results);
|
|
Assert.AreEqual(0, results.Count);
|
|
}
|
|
|
|
[Test]
|
|
public async Task GetActivityAccountDetailsByAccountNumbers_Exception_OK()
|
|
{
|
|
_mockAccountDao.Setup(x => x.GetActivityAccountDetailsByAccountNumbers(It.IsAny<List<string>>()))
|
|
.ThrowsAsync(new Exception("Boo"));
|
|
|
|
Assert.ThrowsAsync<Exception>(async () =>
|
|
await _accountService.GetActivityAccountDetailsByAccountNumbers(new List<long>() { 1, 2, 3 }));
|
|
_mockAccountDao.Verify(x =>
|
|
x.GetActivityAccountDetailsByAccountNumbers(It.Is<List<string>>(x =>
|
|
x.Contains("1") && x.Contains("2") && x.Contains("3"))));
|
|
}
|
|
|
|
[Test]
|
|
public async Task GetOwnersByAccountNumber_OK()
|
|
{
|
|
var returnedAccountNumbers = new List<AccountOwnership>
|
|
{
|
|
new AccountOwnership
|
|
{
|
|
FirstName = "Pete",
|
|
LastName = "Peterson",
|
|
PersonNumber = 12345,
|
|
IsPrimaryOwner = true
|
|
},
|
|
new AccountOwnership
|
|
{
|
|
FirstName = "Bill",
|
|
LastName = "Billson",
|
|
PersonNumber = 98765,
|
|
}
|
|
};
|
|
|
|
_mockAccountDao
|
|
.Setup(x => x.FindOwnersByAccountNumber(It.IsAny<long>(), It.IsAny<DateTime>()))
|
|
.ReturnsAsync(returnedAccountNumbers).Verifiable();
|
|
|
|
var result = await _accountService.GetOwnersByAccountNumber(12345, DateTime.Now);
|
|
Assert.NotNull(result);
|
|
|
|
Assert.AreEqual(result.First().PersonNumber, 12345);
|
|
Assert.AreEqual(result.First().IsPrimaryOwner, true);
|
|
Assert.AreEqual(result.Last().PersonNumber, 98765);
|
|
Assert.AreEqual(result.Last().IsPrimaryOwner, false);
|
|
Assert.AreEqual(result.Count(), 2);
|
|
|
|
_mockAccountDao.Verify();
|
|
}
|
|
|
|
[Test]
|
|
public void GetOwnersByAccountNumber_Exception()
|
|
{
|
|
_mockAccountDao.Setup(x => x.FindOwnersByAccountNumber(It.IsAny<long>(), It.IsAny<DateTime>()))
|
|
.Throws(new Exception("Exception from unit test")).Verifiable();
|
|
|
|
Assert.ThrowsAsync<Exception>(async () => await _accountService.GetOwnersByAccountNumber(12345, DateTime.Now));
|
|
_mockAccountDao.Verify();
|
|
}
|
|
|
|
[Test]
|
|
public async Task GetPrimaryOwnersByPersonName_OK()
|
|
{
|
|
var personName = "Peterson";
|
|
|
|
var returnedAccountNumbers = new List<AccountOwnership>
|
|
{
|
|
new AccountOwnership
|
|
{
|
|
FirstName = "Pete",
|
|
LastName = "Peterson",
|
|
PersonNumber = 12345,
|
|
IsPrimaryOwner = true
|
|
},
|
|
new AccountOwnership
|
|
{
|
|
FirstName = "Paul",
|
|
LastName = "Peterson",
|
|
PersonNumber = 98765,
|
|
}
|
|
};
|
|
|
|
_mockAccountDao
|
|
.Setup(x => x.FindPrimaryOwnersByPersonName(It.IsAny<string>()))
|
|
.ReturnsAsync(returnedAccountNumbers).Verifiable();
|
|
|
|
var result = await _accountService.GetPrimaryOwnersByPersonName(personName);
|
|
Assert.NotNull(result);
|
|
|
|
var firstNameConcat = returnedAccountNumbers.First().FirstName + " " + returnedAccountNumbers.First().LastName;
|
|
var secondNameConcat = returnedAccountNumbers.Last().FirstName + " " + returnedAccountNumbers.Last().LastName;
|
|
Assert.IsTrue(firstNameConcat.Contains(personName));
|
|
Assert.IsTrue(secondNameConcat.Contains(personName));
|
|
Assert.AreEqual(result.First().IsPrimaryOwner, true);
|
|
Assert.AreEqual(result.Last().PersonNumber, 98765);
|
|
Assert.AreEqual(result.Last().IsPrimaryOwner, false);
|
|
Assert.AreEqual(result.Count(), 2);
|
|
|
|
_mockAccountDao.Verify();
|
|
}
|
|
|
|
[Test]
|
|
public void GetPrimaryOwnersByPersonName_Exception()
|
|
{
|
|
var personName = "Pete Peterson";
|
|
|
|
_mockAccountDao.Setup(x => x.FindPrimaryOwnersByPersonName(It.IsAny<string>()))
|
|
.Throws(new ServiceException("Exception from unit test")).Verifiable();
|
|
|
|
Assert.ThrowsAsync<ServiceException>(async () => await _accountService.GetPrimaryOwnersByPersonName(personName));
|
|
_mockAccountDao.Verify();
|
|
}
|
|
|
|
[Test]
|
|
public async Task GetPrimaryOwnersByOrganizationName_OK()
|
|
{
|
|
var organizationName = "The Big Company";
|
|
|
|
var returnedAccountNumbers = new List<AccountOwnership>
|
|
{
|
|
new AccountOwnership
|
|
{
|
|
OrganizationName = organizationName,
|
|
ByOrgNbr = 12345,
|
|
IsPrimaryOwner = true
|
|
}
|
|
};
|
|
|
|
_mockAccountDao
|
|
.Setup(x => x.FindPrimaryOwnersByOrganizationName(It.IsAny<string>()))
|
|
.ReturnsAsync(returnedAccountNumbers).Verifiable();
|
|
|
|
var result = await _accountService.GetPrimaryOwnersByOrganizationName(organizationName);
|
|
Assert.NotNull(result);
|
|
|
|
Assert.AreEqual(result.First().OrganizationName, organizationName);
|
|
Assert.AreEqual(result.First().IsPrimaryOwner, true);
|
|
|
|
_mockAccountDao.Verify();
|
|
}
|
|
|
|
[Test]
|
|
public void GetPrimaryOwnersByOrganizationName_Exception()
|
|
{
|
|
var organizationName = "The Big Company";
|
|
|
|
_mockAccountDao.Setup(x => x.FindPrimaryOwnersByOrganizationName(It.IsAny<string>()))
|
|
.Throws(new ServiceException("Exception from unit test")).Verifiable();
|
|
|
|
Assert.ThrowsAsync<ServiceException>(async () => await _accountService.GetPrimaryOwnersByOrganizationName(organizationName));
|
|
_mockAccountDao.Verify();
|
|
}
|
|
|
|
[Test]
|
|
public async Task GetAccountsForAccoutGroupMaintenance_OK()
|
|
{
|
|
|
|
IEnumerable<string> returnedAccountNumbers = new List<string>
|
|
{
|
|
"22",
|
|
"44"
|
|
};
|
|
|
|
_mockAccountDao.Setup(x => x.FindAccountsToUpdateAccountAnalysis())
|
|
.ReturnsAsync(returnedAccountNumbers).Verifiable();
|
|
|
|
IEnumerable<string> result = await _accountService.GetAccountsForGroupAnalysisMaintenance();
|
|
Assert.NotNull(result);
|
|
Assert.IsTrue(result.ToList().Count > 1);
|
|
_mockAccountDao.Verify();
|
|
}
|
|
|
|
[Test]
|
|
public void GetAccountsForAccoutGroupMaintenance_Exception()
|
|
{
|
|
_mockAccountDao.Setup(x => x.FindAccountsToUpdateAccountAnalysis())
|
|
.Throws(new ServiceException("Exception from unit test")).Verifiable();
|
|
|
|
Assert.ThrowsAsync<ServiceException>(async () => await _accountService.GetAccountsForGroupAnalysisMaintenance());
|
|
_mockAccountDao.Verify();
|
|
}
|
|
|
|
[Test]
|
|
public async Task UpdateAccountsForAccoutGroupMaintenance_OK()
|
|
{
|
|
var accountAnalysisGroupMaintenanceRequest = new AccountAnalysisGroupMaintenanceRequest()
|
|
{
|
|
AccountNumber = 123,
|
|
IsGenerateAnalysisStatement = true,
|
|
IsPrintAnalysisStatement = true,
|
|
IsUseForServiceCharge = true
|
|
};
|
|
|
|
var returnedAccountNumbers = new List<string>
|
|
{
|
|
"22",
|
|
"44"
|
|
};
|
|
|
|
var response = new BasicResponse()
|
|
{
|
|
Success = true
|
|
};
|
|
|
|
_mockAccountDao
|
|
.Setup(x => x.UpdateAccountAnalysis(accountAnalysisGroupMaintenanceRequest))
|
|
.ReturnsAsync(response).Verifiable();
|
|
|
|
var result = await _accountService.UpdateAccountAnalysisMaintenance(accountAnalysisGroupMaintenanceRequest);
|
|
Assert.NotNull(result);
|
|
|
|
Assert.AreEqual(result.Success, true);
|
|
_mockAccountDao.Verify();
|
|
}
|
|
|
|
[Test]
|
|
public void UpdateAccountsForAccoutGroupMaintenance_Exception()
|
|
{
|
|
var accountAnalysisGroupMaintenanceRequest = new AccountAnalysisGroupMaintenanceRequest()
|
|
{
|
|
AccountNumber = 123,
|
|
IsGenerateAnalysisStatement = true,
|
|
IsPrintAnalysisStatement = true,
|
|
IsUseForServiceCharge = true
|
|
};
|
|
_mockAccountDao.Setup(x => x.UpdateAccountAnalysis(accountAnalysisGroupMaintenanceRequest))
|
|
.Throws(new ServiceException("Exception from unit test")).Verifiable();
|
|
|
|
Assert.ThrowsAsync<ServiceException>(async () => await _accountService.UpdateAccountAnalysisMaintenance(accountAnalysisGroupMaintenanceRequest));
|
|
_mockAccountDao.Verify();
|
|
}
|
|
|
|
[Test]
|
|
public async Task PostAccountsForPerson_OK()
|
|
{
|
|
var request = new CreatePersonAccountRequest()
|
|
{
|
|
PersonNumber = 1,
|
|
FirstName = "Test",
|
|
LastName = "Test"
|
|
};
|
|
|
|
var returnedAccountNumbers = new List<long>
|
|
{
|
|
22
|
|
};
|
|
|
|
var response = new CreatedAccountResponse()
|
|
{
|
|
AccountNumber = returnedAccountNumbers[0],
|
|
BasicResponse = new BasicResponse() { Success = true }
|
|
};
|
|
|
|
_mockAccountDao
|
|
.Setup(x => x.AddPersonAccount(request))
|
|
.ReturnsAsync(response).Verifiable();
|
|
|
|
var result = await _accountService.AddPersonAccount(request);
|
|
Assert.NotNull(result);
|
|
|
|
Assert.AreEqual(result.BasicResponse.Success, true);
|
|
_mockAccountDao.Verify();
|
|
}
|
|
|
|
[Test]
|
|
public void PostAccountsForPerson_Exception()
|
|
{
|
|
var request = new CreatePersonAccountRequest()
|
|
{
|
|
PersonNumber = 1,
|
|
FirstName = "Test",
|
|
LastName = "Test"
|
|
};
|
|
|
|
var returnedAccountNumbers = new List<long>
|
|
{
|
|
22
|
|
};
|
|
|
|
var response = new CreatedAccountResponse()
|
|
{
|
|
AccountNumber = returnedAccountNumbers[0],
|
|
BasicResponse = new BasicResponse() { Success = true }
|
|
};
|
|
|
|
_mockAccountDao
|
|
.Setup(x => x.AddPersonAccount(request))
|
|
.Throws(new ServiceException("Exception from unit test")).Verifiable();
|
|
|
|
Assert.ThrowsAsync<ServiceException>(async () => await _accountService.AddPersonAccount(request));
|
|
_mockAccountDao.Verify();
|
|
}
|
|
|
|
[Test]
|
|
public async Task PostAccountsForOrganization_OK()
|
|
{
|
|
var request = new CreateOrganizationAccountRequest()
|
|
{
|
|
OrganizationNumber = 1
|
|
};
|
|
|
|
var returnedAccountNumbers = new List<long>
|
|
{
|
|
22
|
|
};
|
|
|
|
var response = new CreatedAccountResponse()
|
|
{
|
|
AccountNumber = returnedAccountNumbers[0],
|
|
BasicResponse = new BasicResponse() { Success = true }
|
|
};
|
|
|
|
_mockAccountDao
|
|
.Setup(x => x.AddOrganizationAccount(request))
|
|
.ReturnsAsync(response).Verifiable();
|
|
|
|
var result = await _accountService.AddOrganizationAccount(request);
|
|
Assert.NotNull(result);
|
|
|
|
Assert.AreEqual(result.BasicResponse.Success, true);
|
|
_mockAccountDao.Verify();
|
|
}
|
|
|
|
[Test]
|
|
public void PostAccountsForOrganization_Exception()
|
|
{
|
|
var request = new CreateOrganizationAccountRequest()
|
|
{
|
|
OrganizationNumber = 1
|
|
};
|
|
|
|
var returnedAccountNumbers = new List<long>
|
|
{
|
|
22
|
|
};
|
|
|
|
var response = new CreatedAccountResponse()
|
|
{
|
|
AccountNumber = returnedAccountNumbers[0],
|
|
BasicResponse = new BasicResponse() { Success = true }
|
|
};
|
|
|
|
_mockAccountDao
|
|
.Setup(x => x.AddOrganizationAccount(request))
|
|
.Throws(new ServiceException("Exception from unit test")).Verifiable();
|
|
|
|
Assert.ThrowsAsync<ServiceException>(async () => await _accountService.AddOrganizationAccount(request));
|
|
_mockAccountDao.Verify();
|
|
}
|
|
|
|
[Test]
|
|
public async Task AddControlPersonOrgMaintenance_OK()
|
|
{
|
|
var request = new OrganizationMaintenanceRequest()
|
|
{
|
|
ControllingPersonNumber = 1,
|
|
OrganizationNumber = 12
|
|
};
|
|
|
|
var returnedAccountNumbers = new List<long>
|
|
{
|
|
22
|
|
};
|
|
|
|
var response = new BasicResponse()
|
|
{
|
|
Success = true
|
|
};
|
|
|
|
_mockAccountDao
|
|
.Setup(x => x.PutOrganizationMaintenanceRequest(request))
|
|
.ReturnsAsync(response).Verifiable();
|
|
|
|
var result = await _accountService.PutOrganizationMaintenanceRequest(request);
|
|
Assert.NotNull(result);
|
|
|
|
Assert.AreEqual(result.Success, true);
|
|
_mockAccountDao.Verify();
|
|
}
|
|
|
|
[Test]
|
|
public void AddControlPersonOrgMaintenance_Exception()
|
|
{
|
|
var request = new OrganizationMaintenanceRequest()
|
|
{
|
|
ControllingPersonNumber = 1,
|
|
OrganizationNumber = 12
|
|
};
|
|
|
|
var returnedAccountNumbers = new List<long>
|
|
{
|
|
22
|
|
};
|
|
|
|
var response = new BasicResponse()
|
|
{
|
|
Success = true
|
|
};
|
|
|
|
_mockAccountDao
|
|
.Setup(x => x.PutOrganizationMaintenanceRequest(request))
|
|
.Throws(new ServiceException("Exception from unit test")).Verifiable();
|
|
|
|
Assert.ThrowsAsync<ServiceException>(async () => await _accountService.PutOrganizationMaintenanceRequest(request));
|
|
_mockAccountDao.Verify();
|
|
}
|
|
|
|
[Test]
|
|
public async Task AccountNickNameUpdateRequest_OK()
|
|
{
|
|
var accountRequest = new AccountNickNameUpdateRequest()
|
|
{
|
|
AccountNumber = 123,
|
|
AccountDescription = "TestOK"
|
|
};
|
|
|
|
var response = new BasicResponse()
|
|
{
|
|
Success = true
|
|
};
|
|
|
|
_mockAccountDao
|
|
.Setup(x => x.UpdateAccountNickName(accountRequest))
|
|
.ReturnsAsync(response).Verifiable();
|
|
|
|
var result = await _accountService.UpdateAccountNickName(accountRequest);
|
|
Assert.NotNull(result);
|
|
|
|
Assert.AreEqual(result.Success, true);
|
|
_mockAccountDao.Verify();
|
|
}
|
|
|
|
[Test]
|
|
public void AccountNickNameUpdateRequest_Exception()
|
|
{
|
|
var accountRequest = new AccountNickNameUpdateRequest()
|
|
{
|
|
AccountNumber = 123,
|
|
AccountDescription = "TestException"
|
|
};
|
|
|
|
_mockAccountDao.Setup(x => x.UpdateAccountNickName(accountRequest))
|
|
.Throws(new ServiceException("Exception from unit test")).Verifiable();
|
|
|
|
Assert.ThrowsAsync<ServiceException>(async () => await _accountService.UpdateAccountNickName(accountRequest));
|
|
_mockAccountDao.Verify();
|
|
}
|
|
|
|
[Test]
|
|
public async Task AccountCreditReportTypeUpdateRequest_OK()
|
|
{
|
|
var accountRequest = new AccountCreditReportTypeUpdateRequest()
|
|
{
|
|
AccountNumber = 123,
|
|
CreditReportType = "EXCL"
|
|
};
|
|
|
|
var response = new BasicResponse()
|
|
{
|
|
Success = true
|
|
};
|
|
|
|
_mockAccountDao
|
|
.Setup(x => x.UpdateAccountCreditReportType(accountRequest))
|
|
.ReturnsAsync(response).Verifiable();
|
|
|
|
var result = await _accountService.UpdateAccountCreditReportType(accountRequest);
|
|
Assert.NotNull(result);
|
|
|
|
Assert.AreEqual(result.Success, true);
|
|
_mockAccountDao.Verify();
|
|
}
|
|
|
|
[Test]
|
|
public void AccountCreditReportTypeUpdateRequest_Exception()
|
|
{
|
|
var accountRequest = new AccountCreditReportTypeUpdateRequest()
|
|
{
|
|
AccountNumber = 123,
|
|
CreditReportType = "EXCL"
|
|
};
|
|
|
|
_mockAccountDao.Setup(x => x.UpdateAccountCreditReportType(accountRequest))
|
|
.Throws(new ServiceException("Exception from unit test")).Verifiable();
|
|
|
|
Assert.ThrowsAsync<ServiceException>(async () => await _accountService.UpdateAccountCreditReportType(accountRequest));
|
|
_mockAccountDao.Verify();
|
|
}
|
|
|
|
[Test]
|
|
public async Task GetAccountsByMajorMinorBranchAndStatus_Ok()
|
|
{
|
|
var request = new AccountsByMajorMinorBranchAndStatusRequest()
|
|
{
|
|
BranchCodes = new List<long>()
|
|
{
|
|
1234,
|
|
1235
|
|
},
|
|
AccountStatuses = new List<string>()
|
|
{
|
|
"Status"
|
|
},
|
|
MajorTypes = new List<string>()
|
|
{
|
|
"Major"
|
|
},
|
|
MinorTypes = new List<string>()
|
|
{
|
|
"MinorOne",
|
|
"MinorTwo"
|
|
}
|
|
};
|
|
|
|
var response = new List<AccountsByMajorMinorBranchAndStatusResponse>()
|
|
{
|
|
new AccountsByMajorMinorBranchAndStatusResponse()
|
|
{
|
|
AccountNumber = 1234,
|
|
BranchCode = 987654321,
|
|
Name = "Test Name"
|
|
},
|
|
new AccountsByMajorMinorBranchAndStatusResponse()
|
|
{
|
|
AccountNumber = 5678,
|
|
BranchCode = 987654321,
|
|
Name = "Test Name Two"
|
|
}
|
|
};
|
|
|
|
_mockAccountDao.Setup(x => x.GetAccountsByMajorMinorBranchAndStatus(request)).ReturnsAsync(response).Verifiable();
|
|
|
|
var result = await _accountService.GetAccountsByMajorMinorBranchAndStatus(request);
|
|
Assert.NotNull(result);
|
|
|
|
Assert.AreEqual(result.Count(), 2);
|
|
Assert.AreEqual(result.FirstOrDefault().AccountNumber, 1234);
|
|
_mockAccountDao.Verify();
|
|
}
|
|
|
|
[Test]
|
|
public async Task GetAccountsByMajorMinorBranchAndStatus_Exception()
|
|
{
|
|
var request = new AccountsByMajorMinorBranchAndStatusRequest()
|
|
{
|
|
BranchCodes = new List<long>()
|
|
{
|
|
1234,
|
|
1235
|
|
},
|
|
AccountStatuses = new List<string>()
|
|
{
|
|
"Status"
|
|
},
|
|
MajorTypes = new List<string>()
|
|
{
|
|
"Major"
|
|
},
|
|
MinorTypes = new List<string>()
|
|
{
|
|
"MinorOne",
|
|
"MinorTwo"
|
|
}
|
|
};
|
|
|
|
_mockAccountDao.Setup(x => x.GetAccountsByMajorMinorBranchAndStatus(request)).Throws(new ServiceException("Exception from unit test")).Verifiable();
|
|
|
|
Assert.ThrowsAsync<ServiceException>(async () => await _accountService.GetAccountsByMajorMinorBranchAndStatus(request));
|
|
_mockAccountDao.Verify();
|
|
}
|
|
|
|
[Test]
|
|
public async Task AccountContractDateUpdateRequest_OK()
|
|
{
|
|
var accountRequest = new AccountContractDateUpdateRequest
|
|
{
|
|
AccountNumber = 123,
|
|
ContractDate = DateTime.Now
|
|
};
|
|
|
|
var response = new BasicResponse()
|
|
{
|
|
Success = true
|
|
};
|
|
|
|
_mockAccountDao
|
|
.Setup(x => x.UpdateAccountContractDate(accountRequest))
|
|
.ReturnsAsync(response).Verifiable();
|
|
|
|
var result = await _accountService.UpdateAccountContractDate(accountRequest);
|
|
Assert.NotNull(result);
|
|
|
|
Assert.AreEqual(result.Success, true);
|
|
_mockAccountDao.Verify();
|
|
}
|
|
|
|
[Test]
|
|
public void AccountContractDateUpdateRequest_Exception()
|
|
{
|
|
var accountRequest = new AccountContractDateUpdateRequest
|
|
{
|
|
AccountNumber = 123,
|
|
ContractDate = DateTime.Now
|
|
};
|
|
|
|
_mockAccountDao.Setup(x => x.UpdateAccountContractDate(accountRequest))
|
|
.Throws(new ServiceException("Exception from unit test")).Verifiable();
|
|
|
|
Assert.ThrowsAsync<ServiceException>(async () => await _accountService.UpdateAccountContractDate(accountRequest));
|
|
_mockAccountDao.Verify();
|
|
}
|
|
}
|
|
}
|