Adding
This commit is contained in:
+438
@@ -0,0 +1,438 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using LCU.Library.Internal.CoreApiWrapperLib.Configuration;
|
||||
using LCU.Library.Internal.CoreApiWrapperLib.CoreApiUtilities;
|
||||
using LCU.Library.Internal.CoreApiWrapperLib.CoreDbUtilities;
|
||||
using LCU.Library.Internal.CoreApiWrapperLib.DataAccess;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Accounts;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreRequests;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreResponses;
|
||||
using LCU.Library.Internal.ApiSecurity.Models;
|
||||
using LCU.Library.Internal.LcuHttpClient.HttpRequest;
|
||||
using LCU.Library.Internal.CoreApiWrapperLib.Utilities;
|
||||
|
||||
namespace LCU.Api.Internal.CoreApiWrapperTest.DataAccess
|
||||
{
|
||||
public class AccountDaoTest
|
||||
{
|
||||
private IAccountDao _accountDao;
|
||||
private CoreConfiguration _coreConfiguration;
|
||||
private ApiSecurityConfiguration _apiSecurityConfiguration;
|
||||
private Mock<ICoreRequest> _mockCoreRequest;
|
||||
private Mock<ICoreDbExecution> _mockCoreDbExecution;
|
||||
private Mock<IPostRequest> _mockPostRequest;
|
||||
private Mock<IPutRequest> _mockPutRequest;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
_mockCoreDbExecution = new Mock<ICoreDbExecution>();
|
||||
_mockCoreRequest = new Mock<ICoreRequest>();
|
||||
_mockPostRequest = new Mock<IPostRequest>();
|
||||
_mockPutRequest = new Mock<IPutRequest>();
|
||||
|
||||
_coreConfiguration = new CoreConfiguration()
|
||||
{
|
||||
CoreSoapApiConfiguration = new CoreSoapApiConfiguration()
|
||||
{
|
||||
CoreSoapApiWrapperHost = "test.lcu-internal.com",
|
||||
CoreSoapEndpointConfiguration = new CoreSoapEndpointConfiguration()
|
||||
{
|
||||
PutAccountAnalysisGroupMaintenanceRequest = "TEST/Account/AccountAnalysisGroupMaintenanceRequest"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
_apiSecurityConfiguration = new ApiSecurityConfiguration()
|
||||
{
|
||||
InternalApiKeySet = new Dictionary<string, string>()
|
||||
{
|
||||
["CoreSoapApiWrapper"] = "TEST"
|
||||
}
|
||||
};
|
||||
|
||||
_accountDao = new AccountDao(_mockCoreRequest.Object,
|
||||
_coreConfiguration,
|
||||
_apiSecurityConfiguration,
|
||||
_mockCoreDbExecution.Object,
|
||||
_mockPostRequest.Object,
|
||||
_mockPutRequest.Object);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetActivityAccountDetailsByAccountNumbers_OK()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<ActivityAccountDetails, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ReturnsAsync(new List<ActivityAccountDetails>()
|
||||
{
|
||||
new() {AccountNumber = 1},
|
||||
new() {AccountNumber = 2},
|
||||
new() {AccountNumber = 3}
|
||||
}).Verifiable();
|
||||
|
||||
var results = await _accountDao.GetActivityAccountDetailsByAccountNumbers(new List<string>() { "1", "2", "3" });
|
||||
Assert.NotNull(results);
|
||||
Assert.AreEqual(3,results.Count);
|
||||
|
||||
_mockCoreDbExecution.Verify(x =>
|
||||
x.ExecuteQuery<ActivityAccountDetails, object>(It.Is<string>(str => str.Contains("ActivityAccountDetailsByAccountNbr") && str.Contains(":accountNumbers")),
|
||||
It.IsAny<It.IsAnyType>()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetActivityAccountDetailsByAccountNumbers_Exception()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<ActivityAccountDetails, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ThrowsAsync(new Exception("Oops"));
|
||||
|
||||
Assert.ThrowsAsync<Exception>(async () =>
|
||||
await _accountDao.GetActivityAccountDetailsByAccountNumbers(new List<string>() { "1", "2", "3" }));
|
||||
|
||||
|
||||
_mockCoreDbExecution.Verify(x =>
|
||||
x.ExecuteQuery<ActivityAccountDetails, object>(It.Is<string>(str => str.Contains("ActivityAccountDetailsByAccountNbr") && str.Contains(":accountNumbers")),
|
||||
It.IsAny<It.IsAnyType>()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task FindOwnersByAccountNumber_OK()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<AccountOwnership, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ReturnsAsync(new List<AccountOwnership> { new AccountOwnership() { FirstName = "Tim" } }).Verifiable();
|
||||
|
||||
var result = await _accountDao.FindOwnersByAccountNumber(12345, new DateTime());
|
||||
|
||||
Assert.NotNull(result);
|
||||
var firstResult = result.First();
|
||||
Assert.AreEqual(firstResult.FirstName, "Tim");
|
||||
_mockCoreDbExecution.Verify();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FindOwnersByAccountNumber_Exception()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<AccountOwnership, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ThrowsAsync(new Exception("Error thrown from unit test"));
|
||||
|
||||
Assert.ThrowsAsync<Exception>(async () => await _accountDao.FindOwnersByAccountNumber(12345, new DateTime()));
|
||||
|
||||
_mockCoreDbExecution.Verify();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task FindOwnersByPersonName_OK()
|
||||
{
|
||||
var firstName = "Tim";
|
||||
var role = "OWN";
|
||||
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<AccountOwnership, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ReturnsAsync(new List<AccountOwnership> { new AccountOwnership() { FirstName = firstName, Role = role } }).Verifiable();
|
||||
|
||||
var result = await _accountDao.FindPrimaryOwnersByPersonName(firstName);
|
||||
|
||||
Assert.NotNull(result);
|
||||
var firstResult = result.First();
|
||||
Assert.AreEqual(firstResult.FirstName, firstName);
|
||||
Assert.AreEqual(firstResult.Role, role);
|
||||
_mockCoreDbExecution.Verify();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FindOwnersByPersonName_Exception()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<AccountOwnership, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ThrowsAsync(new Exception("Error thrown from unit test"));
|
||||
|
||||
Assert.ThrowsAsync<Exception>(async () => await _accountDao.FindPrimaryOwnersByPersonName("Tim"));
|
||||
|
||||
_mockCoreDbExecution.Verify();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task FindOwnersByOrganizationName_OK()
|
||||
{
|
||||
var organizationName = "The Big Company";
|
||||
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<AccountOwnership, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ReturnsAsync(new List<AccountOwnership> { new AccountOwnership() { OrganizationName = organizationName } }).Verifiable();
|
||||
|
||||
var result = await _accountDao.FindPrimaryOwnersByOrganizationName(organizationName);
|
||||
|
||||
Assert.NotNull(result);
|
||||
var firstResult = result.First();
|
||||
Assert.AreEqual(firstResult.OrganizationName, organizationName);
|
||||
_mockCoreDbExecution.Verify();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FindOwnersByOrganizationName_Exception()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<AccountOwnership, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ThrowsAsync(new Exception("Error thrown from unit test"));
|
||||
|
||||
Assert.ThrowsAsync<Exception>(async () => await _accountDao.FindPrimaryOwnersByOrganizationName("The Big Company"));
|
||||
|
||||
_mockCoreDbExecution.Verify();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task FindAccountsForGroupAnalysisUpdate_OK()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<string>(It.IsAny<string>()))
|
||||
.ReturnsAsync(new List<string> { { "11111111" }, { "22222222" } }).Verifiable();
|
||||
|
||||
var result = await _accountDao.FindAccountsToUpdateAccountAnalysis();
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(result.First(), "11111111");
|
||||
_mockCoreDbExecution.Verify();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task FindAccountsForGroupAnalysisUpdate_Exception()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<string, object>(null, null))
|
||||
.ThrowsAsync(new Exception("Error thrown from unit test"));
|
||||
_mockCoreDbExecution.Verify();
|
||||
var result = await _accountDao.FindAccountsToUpdateAccountAnalysis();
|
||||
|
||||
Assert.IsEmpty(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task UpdateAccountsForGroupAnalysisUpdate_OK()
|
||||
{
|
||||
var accountAnalysisGroupMaintenanceRequest = new AccountAnalysisGroupMaintenanceRequest()
|
||||
{
|
||||
AccountNumber = 123,
|
||||
IsGenerateAnalysisStatement = true,
|
||||
IsPrintAnalysisStatement = true,
|
||||
IsUseForServiceCharge = true
|
||||
};
|
||||
|
||||
var basicResponse = new BasicResponse()
|
||||
{
|
||||
Success = true
|
||||
};
|
||||
|
||||
var endpoint = HttpUtilities.BuildHttpsUri(_coreConfiguration.CoreSoapApiConfiguration.CoreSoapApiWrapperHost,
|
||||
_coreConfiguration.CoreSoapApiConfiguration.CoreSoapEndpointConfiguration.PutAccountAnalysisGroupMaintenanceRequest);
|
||||
_mockPutRequest.Setup(x => x.Async<AccountAnalysisGroupMaintenanceRequest, BasicResponse>(endpoint,
|
||||
It.IsAny<AccountAnalysisGroupMaintenanceRequest>(),
|
||||
It.IsAny<Dictionary<string, string>>(),
|
||||
It.IsAny<int>(),
|
||||
It.IsAny<int>()))
|
||||
.ReturnsAsync(basicResponse).Verifiable();
|
||||
|
||||
var result = await _accountDao.UpdateAccountAnalysis(accountAnalysisGroupMaintenanceRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(result.Success, true);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task UpdateAccountsForGroupAnalysisUpdate_Exception()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<string, object>(null, null))
|
||||
.ThrowsAsync(new Exception("Error thrown from unit test"));
|
||||
_mockCoreDbExecution.Verify();
|
||||
var result = await _accountDao.FindAccountsToUpdateAccountAnalysis();
|
||||
|
||||
Assert.IsEmpty(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task UpdateAccountNickName_OK()
|
||||
{
|
||||
var accountRequest = new AccountNickNameUpdateRequest()
|
||||
{
|
||||
AccountNumber = 123,
|
||||
AccountDescription = "TestOk"
|
||||
};
|
||||
|
||||
var basicResponse = new BasicResponse()
|
||||
{
|
||||
Success = true
|
||||
};
|
||||
|
||||
var endpoint = HttpUtilities.BuildHttpsUri(_coreConfiguration.CoreSoapApiConfiguration.CoreSoapApiWrapperHost,
|
||||
_coreConfiguration.CoreSoapApiConfiguration.CoreSoapEndpointConfiguration.PutAccountNickNameUpdateRequest);
|
||||
_mockPutRequest.Setup(x => x.Async<AccountNickNameUpdateRequest, BasicResponse>(endpoint,
|
||||
It.IsAny<AccountNickNameUpdateRequest>(),
|
||||
It.IsAny<Dictionary<string, string>>(),
|
||||
It.IsAny<int>(),
|
||||
It.IsAny<int>()))
|
||||
.ReturnsAsync(basicResponse).Verifiable();
|
||||
|
||||
var result = await _accountDao.UpdateAccountNickName(accountRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(result.Success, true);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task UpdateAccountNickName_Exception()
|
||||
{
|
||||
var accountRequest = new AccountNickNameUpdateRequest()
|
||||
{
|
||||
AccountNumber = 0,
|
||||
AccountDescription = "TestError"
|
||||
};
|
||||
var result = await _accountDao.UpdateAccountNickName(accountRequest);
|
||||
|
||||
Assert.IsNull(result);
|
||||
}
|
||||
[Test]
|
||||
public async Task UpdateAccountCreditReportType_OK()
|
||||
{
|
||||
var accountRequest = new AccountCreditReportTypeUpdateRequest()
|
||||
{
|
||||
AccountNumber = 123,
|
||||
CreditReportType = "EXCL"
|
||||
};
|
||||
|
||||
var basicResponse = new BasicResponse()
|
||||
{
|
||||
Success = true
|
||||
};
|
||||
|
||||
var endpoint = HttpUtilities.BuildHttpsUri(_coreConfiguration.CoreSoapApiConfiguration.CoreSoapApiWrapperHost,
|
||||
_coreConfiguration.CoreSoapApiConfiguration.CoreSoapEndpointConfiguration.PutAccountCreditReportTypeUpdateRequest);
|
||||
_mockPutRequest.Setup(x => x.Async<AccountCreditReportTypeUpdateRequest, BasicResponse>(endpoint,
|
||||
It.IsAny<AccountCreditReportTypeUpdateRequest>(),
|
||||
It.IsAny<Dictionary<string, string>>(),
|
||||
It.IsAny<int>(),
|
||||
It.IsAny<int>()))
|
||||
.ReturnsAsync(basicResponse).Verifiable();
|
||||
|
||||
var result = await _accountDao.UpdateAccountCreditReportType(accountRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(result.Success, true);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task UpdateAccountCreditReportType_Exception()
|
||||
{
|
||||
var accountRequest = new AccountCreditReportTypeUpdateRequest()
|
||||
{
|
||||
AccountNumber = 0,
|
||||
CreditReportType = "EXCL"
|
||||
};
|
||||
var result = await _accountDao.UpdateAccountCreditReportType(accountRequest);
|
||||
|
||||
Assert.IsNull(result);
|
||||
}
|
||||
|
||||
[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"
|
||||
}
|
||||
};
|
||||
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<AccountsByMajorMinorBranchAndStatusResponse, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ReturnsAsync(response).Verifiable();
|
||||
|
||||
var result = await _accountDao.GetAccountsByMajorMinorBranchAndStatus(request);
|
||||
|
||||
Assert.NotNull(result);
|
||||
var firstResult = result.First();
|
||||
Assert.AreEqual(firstResult.AccountNumber, 1234);
|
||||
Assert.AreEqual(firstResult.Name, "Test Name");
|
||||
_mockCoreDbExecution.Verify();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task UpdateAccountContractDate_OK()
|
||||
{
|
||||
var accountRequest = new AccountContractDateUpdateRequest
|
||||
{
|
||||
AccountNumber = 123,
|
||||
ContractDate = DateTime.Now
|
||||
};
|
||||
|
||||
var basicResponse = new BasicResponse()
|
||||
{
|
||||
Success = true
|
||||
};
|
||||
|
||||
var endpoint = HttpUtilities.BuildHttpsUri(_coreConfiguration.CoreSoapApiConfiguration.CoreSoapApiWrapperHost,
|
||||
_coreConfiguration.CoreSoapApiConfiguration.CoreSoapEndpointConfiguration.PutAccountContractDateUpdateRequest);
|
||||
_mockPutRequest.Setup(x => x.Async<AccountContractDateUpdateRequest, BasicResponse>(endpoint,
|
||||
It.IsAny<AccountContractDateUpdateRequest>(),
|
||||
It.IsAny<Dictionary<string, string>>(),
|
||||
It.IsAny<int>(),
|
||||
It.IsAny<int>()))
|
||||
.ReturnsAsync(basicResponse).Verifiable();
|
||||
|
||||
var result = await _accountDao.UpdateAccountContractDate(accountRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(result.Success, true);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task UpdateAccountContractDate_Exception()
|
||||
{
|
||||
var accountRequest = new AccountContractDateUpdateRequest
|
||||
{
|
||||
AccountNumber = 123,
|
||||
ContractDate = DateTime.Now
|
||||
};
|
||||
var result = await _accountDao.UpdateAccountContractDate(accountRequest);
|
||||
|
||||
Assert.IsNull(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
+652
@@ -0,0 +1,652 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using LCU.Library.Internal.CoreApiWrapperLib.CoreDbUtilities;
|
||||
using LCU.Library.Internal.CoreApiWrapperLib.DataAccess;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Activity;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.LcuModels.Activity;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.LcuModels.Phones;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace LCU.Api.Internal.CoreApiWrapperTest.DataAccess
|
||||
{
|
||||
public class ActivityDaoTest
|
||||
{
|
||||
private ActivityDao _activityDao;
|
||||
private Mock<ICoreDbExecution> _mockCoreDbExecution;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
_mockCoreDbExecution = new Mock<ICoreDbExecution>();
|
||||
_activityDao = new ActivityDao(_mockCoreDbExecution.Object);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetNewCheckingActivities_OK()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<NewCheckingAccountActivity, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ReturnsAsync(new List<NewCheckingAccountActivity>()
|
||||
{
|
||||
new NewCheckingAccountActivity() { ActivityNbr = 1 },
|
||||
new NewCheckingAccountActivity() { ActivityNbr = 2 },
|
||||
new NewCheckingAccountActivity() { ActivityNbr = 3 }
|
||||
}).Verifiable();
|
||||
|
||||
var results = await _activityDao.GetNewCheckingActivities(DateTime.Parse("2020-04-02T11:00:00"), 1, 100);
|
||||
|
||||
Assert.NotNull(results);
|
||||
Assert.AreEqual(3, results.Count);
|
||||
//Parameters are passed in using Anonymous Object, Verify they are expected object using HashCode. Obj.Equals has issues with Anonymous Objects.
|
||||
_mockCoreDbExecution.Verify(x =>
|
||||
x.ExecuteQuery<NewCheckingAccountActivity, object>(It.Is<string>(str => str.Contains(":newerThanDateTime")),
|
||||
It.Is<object>(obj =>
|
||||
obj.GetHashCode()
|
||||
.Equals(new { afterActivityNbr = "1", newerThanDateTime = "2020-04-02 11:00:00", limitAmount = "100" }.GetHashCode()))));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetNewCheckingActivities_Exception()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<NewCheckingAccountActivity, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ThrowsAsync(new Exception("Yikes"));
|
||||
|
||||
Assert.ThrowsAsync<Exception>(async () =>
|
||||
await _activityDao.GetNewCheckingActivities(DateTime.Parse("2020-04-02T11:00:00"), 1, 100));
|
||||
|
||||
//Parameters are passed in using Anonymous Object,Verify they are expected object using HashCode. Obj.Equals has issues with Anonymous Objects.
|
||||
_mockCoreDbExecution.Verify(x =>
|
||||
x.ExecuteQuery<NewCheckingAccountActivity, object>(It.Is<string>(str => str.Contains(":newerThanDateTime")),
|
||||
It.Is<object>(obj =>
|
||||
obj.GetHashCode().Equals(new { newerThanDateTime = "2020-04-02 11:00:00", afterActivityNbr = "1" }.GetHashCode()))), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetNewCheckingActivitiesNewerThanDate_OK()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<NewCheckingAccountActivity, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ReturnsAsync(new List<NewCheckingAccountActivity>()
|
||||
{
|
||||
new NewCheckingAccountActivity() { ActivityNbr = 1 },
|
||||
new NewCheckingAccountActivity() { ActivityNbr = 2 },
|
||||
new NewCheckingAccountActivity() { ActivityNbr = 3 }
|
||||
}).Verifiable();
|
||||
|
||||
var results = await _activityDao.GetNewCheckingActivitiesNewerThanDate(DateTime.Parse("2020-04-02T11:00:00"), 100);
|
||||
|
||||
Assert.NotNull(results);
|
||||
Assert.AreEqual(3, results.Count);
|
||||
//Parameters are passed in using Anonymous Object, Verify they are expected object using HashCode. Obj.Equals has issues with Anonymous Objects.
|
||||
_mockCoreDbExecution.Verify(x =>
|
||||
x.ExecuteQuery<NewCheckingAccountActivity, object>(It.Is<string>(str => str.Contains(":newerThanDateTime")),
|
||||
It.Is<object>(obj =>
|
||||
obj.GetHashCode().Equals(new { newerThanDateTime = "2020-04-02 11:00:00", afterActivityNbr = (string)null, limitAmount = "100" }
|
||||
.GetHashCode()))));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetNewCheckingActivitiesNewerThanDate()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<NewCheckingAccountActivity, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ThrowsAsync(new Exception("Yikes"));
|
||||
|
||||
Assert.ThrowsAsync<Exception>(async () =>
|
||||
await _activityDao.GetNewCheckingActivitiesNewerThanDate(DateTime.Parse("2020-04-02T11:00:00"), 100));
|
||||
|
||||
//Parameters are passed in using Anonymous Object,Verify they are expected object using HashCode. Obj.Equals has issues with Anonymous Objects.
|
||||
_mockCoreDbExecution.Verify(x =>
|
||||
x.ExecuteQuery<NewCheckingAccountActivity, object>(It.Is<string>(str => str.Contains(":newerThanDateTime")),
|
||||
It.Is<object>(obj =>
|
||||
obj.GetHashCode().Equals(new { newerThanDateTime = "2020-04-02 11:00:00", afterActivityNbr = (string)null, limitAmount = "100" }
|
||||
.GetHashCode()))));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetNewCheckingActivitiesAfterActivityNbr_OK()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<NewCheckingAccountActivity, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ReturnsAsync(new List<NewCheckingAccountActivity>()
|
||||
{
|
||||
new NewCheckingAccountActivity() { ActivityNbr = 1 },
|
||||
new NewCheckingAccountActivity() { ActivityNbr = 2 },
|
||||
new NewCheckingAccountActivity() { ActivityNbr = 3 }
|
||||
}).Verifiable();
|
||||
|
||||
var results = await _activityDao.GetNewCheckingActivitiesAfterActivityNbr(1, 100);
|
||||
|
||||
Assert.NotNull(results);
|
||||
Assert.AreEqual(3, results.Count);
|
||||
//Parameters are passed in using Anonymous Object, Verify they are expected object using HashCode. Obj.Equals has issues with Anonymous Objects.
|
||||
_mockCoreDbExecution.Verify(x =>
|
||||
x.ExecuteQuery<NewCheckingAccountActivity, object>(It.Is<string>(str => str.Contains(":newerThanDateTime")),
|
||||
It.Is<object>(obj =>
|
||||
obj.GetHashCode().Equals(new { newerThanDateTime = (string)null, afterActivityNbr = "1" }.GetHashCode()))), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetNewCheckingActivitiesAfterActivityNbr_Exception()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<NewCheckingAccountActivity, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ThrowsAsync(new Exception("Yikes"));
|
||||
|
||||
Assert.ThrowsAsync<Exception>(async () =>
|
||||
await _activityDao.GetNewCheckingActivitiesAfterActivityNbr(1, 100));
|
||||
|
||||
//Parameters are passed in using Anonymous Object,Verify they are expected object using HashCode. Obj.Equals has issues with Anonymous Objects.
|
||||
_mockCoreDbExecution.Verify(x =>
|
||||
x.ExecuteQuery<NewCheckingAccountActivity, object>(It.Is<string>(str => str.Contains(":newerThanDateTime")),
|
||||
It.Is<object>(obj =>
|
||||
obj.GetHashCode().Equals(new { newerThanDateTime = (string)null, afterActivityNbr = "1" }.GetHashCode()))), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetNewAtmCheckCardActivities_OK()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<NewAtmCheckCardActivity, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ReturnsAsync(new List<NewAtmCheckCardActivity>()
|
||||
{
|
||||
new NewAtmCheckCardActivity() { ActivityNbr = 1 },
|
||||
new NewAtmCheckCardActivity() { ActivityNbr = 2 },
|
||||
new NewAtmCheckCardActivity() { ActivityNbr = 3 }
|
||||
}).Verifiable();
|
||||
|
||||
var results = await _activityDao.GetNewAtmCheckCardActivities(DateTime.Parse("2020-04-02T11:00:00"), 1, 100);
|
||||
|
||||
Assert.NotNull(results);
|
||||
Assert.AreEqual(3, results.Count);
|
||||
//Parameters are passed in using Anonymous Object, Verify they are expected object using HashCode. Obj.Equals has issues with Anonymous Objects.
|
||||
_mockCoreDbExecution.Verify(x =>
|
||||
x.ExecuteQuery<NewAtmCheckCardActivity, object>(It.Is<string>(str => str.Contains(":newerThanDateTime")),
|
||||
It.Is<object>(obj =>
|
||||
obj.GetHashCode()
|
||||
.Equals(new { afterActivityNbr = "1", newerThanDateTime = "2020-04-02 11:00:00", limitAmount = "100" }.GetHashCode()))));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetNewAtmCheckCardActivities_Exception()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<NewAtmCheckCardActivity, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ThrowsAsync(new Exception("Yikes"));
|
||||
|
||||
Assert.ThrowsAsync<Exception>(async () =>
|
||||
await _activityDao.GetNewAtmCheckCardActivities(DateTime.Parse("2020-04-02T11:00:00"), 1, 100));
|
||||
|
||||
//Parameters are passed in using Anonymous Object,Verify they are expected object using HashCode. Obj.Equals has issues with Anonymous Objects.
|
||||
_mockCoreDbExecution.Verify(x =>
|
||||
x.ExecuteQuery<NewAtmCheckCardActivity, object>(It.Is<string>(str => str.Contains(":newerThanDateTime")),
|
||||
It.Is<object>(obj =>
|
||||
obj.GetHashCode().Equals(new { newerThanDateTime = "2020-04-02 11:00:00", afterActivityNbr = "1" }.GetHashCode()))), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetNewAtmCheckCardActivitiesNewerThanDate_OK()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<NewAtmCheckCardActivity, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ReturnsAsync(new List<NewAtmCheckCardActivity>()
|
||||
{
|
||||
new NewAtmCheckCardActivity() { ActivityNbr = 1 },
|
||||
new NewAtmCheckCardActivity() { ActivityNbr = 2 },
|
||||
new NewAtmCheckCardActivity() { ActivityNbr = 3 }
|
||||
}).Verifiable();
|
||||
|
||||
var results = await _activityDao.GetNewAtmCheckCardActivitiesNewerThanDate(DateTime.Parse("2020-04-02T11:00:00"), 100);
|
||||
|
||||
Assert.NotNull(results);
|
||||
Assert.AreEqual(3, results.Count);
|
||||
//Parameters are passed in using Anonymous Object, Verify they are expected object using HashCode. Obj.Equals has issues with Anonymous Objects.
|
||||
_mockCoreDbExecution.Verify(x =>
|
||||
x.ExecuteQuery<NewAtmCheckCardActivity, object>(It.Is<string>(str => str.Contains(":newerThanDateTime")),
|
||||
It.Is<object>(obj =>
|
||||
obj.GetHashCode().Equals(new { newerThanDateTime = "2020-04-02 11:00:00", afterActivityNbr = (string)null, limitAmount = "100" }
|
||||
.GetHashCode()))));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetNewAtmCheckCardActivitiesNewerThanDate()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<NewAtmCheckCardActivity, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ThrowsAsync(new Exception("Yikes"));
|
||||
|
||||
Assert.ThrowsAsync<Exception>(async () =>
|
||||
await _activityDao.GetNewAtmCheckCardActivitiesNewerThanDate(DateTime.Parse("2020-04-02T11:00:00"), 100));
|
||||
|
||||
//Parameters are passed in using Anonymous Object,Verify they are expected object using HashCode. Obj.Equals has issues with Anonymous Objects.
|
||||
_mockCoreDbExecution.Verify(x =>
|
||||
x.ExecuteQuery<NewAtmCheckCardActivity, object>(It.Is<string>(str => str.Contains(":newerThanDateTime")),
|
||||
It.Is<object>(obj =>
|
||||
obj.GetHashCode().Equals(new { newerThanDateTime = "2020-04-02 11:00:00", afterActivityNbr = (string)null, limitAmount = "100" }
|
||||
.GetHashCode()))));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetNewAtmCheckCardActivitiesAfterActivityNbr_OK()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<NewAtmCheckCardActivity, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ReturnsAsync(new List<NewAtmCheckCardActivity>()
|
||||
{
|
||||
new NewAtmCheckCardActivity() { ActivityNbr = 1 },
|
||||
new NewAtmCheckCardActivity() { ActivityNbr = 2 },
|
||||
new NewAtmCheckCardActivity() { ActivityNbr = 3 }
|
||||
}).Verifiable();
|
||||
|
||||
var results = await _activityDao.GetNewAtmCheckCardActivitiesAfterActivityNbr(1, 100);
|
||||
|
||||
Assert.NotNull(results);
|
||||
Assert.AreEqual(3, results.Count);
|
||||
//Parameters are passed in using Anonymous Object, Verify they are expected object using HashCode. Obj.Equals has issues with Anonymous Objects.
|
||||
_mockCoreDbExecution.Verify(x =>
|
||||
x.ExecuteQuery<NewAtmCheckCardActivity, object>(It.Is<string>(str => str.Contains(":newerThanDateTime")),
|
||||
It.Is<object>(obj =>
|
||||
obj.GetHashCode().Equals(new { newerThanDateTime = (string)null, afterActivityNbr = "1" }.GetHashCode()))), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetNewAtmCheckCardActivitiesAfterActivityNbr_Exception()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<NewAtmCheckCardActivity, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ThrowsAsync(new Exception("Yikes"));
|
||||
|
||||
Assert.ThrowsAsync<Exception>(async () =>
|
||||
await _activityDao.GetNewAtmCheckCardActivitiesAfterActivityNbr(1, 100));
|
||||
|
||||
//Parameters are passed in using Anonymous Object,Verify they are expected object using HashCode. Obj.Equals has issues with Anonymous Objects.
|
||||
_mockCoreDbExecution.Verify(x =>
|
||||
x.ExecuteQuery<NewAtmCheckCardActivity, object>(It.Is<string>(str => str.Contains(":newerThanDateTime")),
|
||||
It.Is<object>(obj =>
|
||||
obj.GetHashCode().Equals(new { newerThanDateTime = (string)null, afterActivityNbr = "1" }.GetHashCode()))), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetNewActivityManagerReferrals_OK()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<NewActivityManagerIncentiveReferral, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ReturnsAsync(new List<NewActivityManagerIncentiveReferral>()
|
||||
{
|
||||
new NewActivityManagerIncentiveReferral() { ActivityId = 1 },
|
||||
new NewActivityManagerIncentiveReferral() { ActivityId = 2 },
|
||||
new NewActivityManagerIncentiveReferral() { ActivityId = 3 }
|
||||
}).Verifiable();
|
||||
|
||||
var results = await _activityDao.GetNewActivityManagerReferrals(DateTime.Parse("2020-04-02T11:00:00"), 1);
|
||||
|
||||
Assert.NotNull(results);
|
||||
Assert.AreEqual(3, results.Count);
|
||||
//Parameters are passed in using Anonymous Object, Verify they are expected object using HashCode. Obj.Equals has issues with Anonymous Objects.
|
||||
_mockCoreDbExecution.Verify(x =>
|
||||
x.ExecuteQuery<NewActivityManagerIncentiveReferral, object>(It.Is<string>(str => str.Contains(":newerThanOriginationDate")),
|
||||
It.Is<object>(obj =>
|
||||
obj.GetHashCode().Equals(new { afterActivityId = "1", newerThanOriginationDate = "2020-04-02 11:00:00" }.GetHashCode()))));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetNewActivityManagerReferrals_Exception()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<NewActivityManagerIncentiveReferral, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ThrowsAsync(new Exception("Yikes"));
|
||||
|
||||
Assert.ThrowsAsync<Exception>(async () =>
|
||||
await _activityDao.GetNewActivityManagerReferrals(DateTime.Parse("2020-04-02T11:00:00"), 1));
|
||||
|
||||
//Parameters are passed in using Anonymous Object,Verify they are expected object using HashCode. Obj.Equals has issues with Anonymous Objects.
|
||||
_mockCoreDbExecution.Verify(x =>
|
||||
x.ExecuteQuery<NewActivityManagerIncentiveReferral, object>(It.Is<string>(str => str.Contains(":newerThanOriginationDate")),
|
||||
It.Is<object>(obj =>
|
||||
obj.GetHashCode().Equals(new { newerThanOriginationDate = "2020-04-02 11:00:00", afterActivityId = "1" }.GetHashCode()))), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetNewActivityManagerReferralsNewerThan_OK()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<NewActivityManagerIncentiveReferral, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ReturnsAsync(new List<NewActivityManagerIncentiveReferral>()
|
||||
{
|
||||
new NewActivityManagerIncentiveReferral() { ActivityId = 1 },
|
||||
new NewActivityManagerIncentiveReferral() { ActivityId = 2 },
|
||||
new NewActivityManagerIncentiveReferral() { ActivityId = 3 }
|
||||
}).Verifiable();
|
||||
|
||||
var results = await _activityDao.GetNewActivityManagerReferralsNewerThan(DateTime.Parse("2020-04-02T11:00:00"));
|
||||
|
||||
Assert.NotNull(results);
|
||||
Assert.AreEqual(3, results.Count);
|
||||
//Parameters are passed in using Anonymous Object, Verify they are expected object using HashCode. Obj.Equals has issues with Anonymous Objects.
|
||||
_mockCoreDbExecution.Verify(x =>
|
||||
x.ExecuteQuery<NewActivityManagerIncentiveReferral, object>(It.Is<string>(str => str.Contains(":newerThanOriginationDate")),
|
||||
It.Is<object>(obj =>
|
||||
obj.GetHashCode().Equals(new { newerThanOriginationDate = "2020-04-02 11:00:00", afterActivityId = (string)null }.GetHashCode()))));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetNewActivityManagerReferralsNewerThan_Exception()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<NewActivityManagerIncentiveReferral, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ThrowsAsync(new Exception("Yikes"));
|
||||
|
||||
Assert.ThrowsAsync<Exception>(async () =>
|
||||
await _activityDao.GetNewActivityManagerReferralsNewerThan(DateTime.Parse("2020-04-02T11:00:00")));
|
||||
|
||||
//Parameters are passed in using Anonymous Object,Verify they are expected object using HashCode. Obj.Equals has issues with Anonymous Objects.
|
||||
_mockCoreDbExecution.Verify(x =>
|
||||
x.ExecuteQuery<NewActivityManagerIncentiveReferral, object>(It.Is<string>(str => str.Contains(":newerThanOriginationDate")),
|
||||
It.Is<object>(obj =>
|
||||
obj.GetHashCode().Equals(new { newerThanOriginationDate = "2020-04-02 11:00:00", afterActivityId = (string)null }.GetHashCode()))));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetNewActivityManagerReferralsAfterActivityId_OK()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<NewActivityManagerIncentiveReferral, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ReturnsAsync(new List<NewActivityManagerIncentiveReferral>()
|
||||
{
|
||||
new NewActivityManagerIncentiveReferral() { ActivityId = 1 },
|
||||
new NewActivityManagerIncentiveReferral() { ActivityId = 2 },
|
||||
new NewActivityManagerIncentiveReferral() { ActivityId = 3 }
|
||||
}).Verifiable();
|
||||
|
||||
var results = await _activityDao.GetNewActivityManagerReferralsAfterActivityId(1);
|
||||
|
||||
Assert.NotNull(results);
|
||||
Assert.AreEqual(3, results.Count);
|
||||
//Parameters are passed in using Anonymous Object, Verify they are expected object using HashCode. Obj.Equals has issues with Anonymous Objects.
|
||||
_mockCoreDbExecution.Verify(x =>
|
||||
x.ExecuteQuery<NewActivityManagerIncentiveReferral, object>(It.Is<string>(str => str.Contains(":newerThanOriginationDate")),
|
||||
It.Is<object>(obj =>
|
||||
obj.GetHashCode().Equals(new { newerThanOriginationDate = (string)null, afterActivityId = "1" }.GetHashCode()))), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetNewActivityManagerReferralsAfterActivityId_Exception()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<NewActivityManagerIncentiveReferral, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ThrowsAsync(new Exception("Yikes"));
|
||||
|
||||
Assert.ThrowsAsync<Exception>(async () =>
|
||||
await _activityDao.GetNewActivityManagerReferralsAfterActivityId(1));
|
||||
|
||||
//Parameters are passed in using Anonymous Object,Verify they are expected object using HashCode. Obj.Equals has issues with Anonymous Objects.
|
||||
_mockCoreDbExecution.Verify(x =>
|
||||
x.ExecuteQuery<NewActivityManagerIncentiveReferral, object>(It.Is<string>(str => str.Contains(":newerThanOriginationDate")),
|
||||
It.Is<object>(obj =>
|
||||
obj.GetHashCode().Equals(new { newerThanOriginationDate = (string)null, afterActivityId = "1" }.GetHashCode()))), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetNewMortgageSaleActivities_OK()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<NewLoanSaleActivity, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ReturnsAsync(new List<NewLoanSaleActivity>()
|
||||
{
|
||||
new NewLoanSaleActivity() { ActivityNbr = 1 },
|
||||
new NewLoanSaleActivity() { ActivityNbr = 2 },
|
||||
new NewLoanSaleActivity() { ActivityNbr = 3 }
|
||||
}).Verifiable();
|
||||
|
||||
var results = await _activityDao.GetNewMortgageSaleActivities(DateTime.Parse("2020-04-02T11:00:00"), 1);
|
||||
|
||||
Assert.NotNull(results);
|
||||
Assert.AreEqual(3, results.Count);
|
||||
//Parameters are passed in using Anonymous Object, Verify they are expected object using HashCode. Obj.Equals has issues with Anonymous Objects.
|
||||
_mockCoreDbExecution.Verify(x =>
|
||||
x.ExecuteQuery<NewLoanSaleActivity, object>(It.Is<string>(str => str.Contains(":newerThanDateTime")),
|
||||
It.Is<object>(obj =>
|
||||
obj.GetHashCode().Equals(new { afterActivityNbr = "1", newerThanDateTime = "2020-04-02 11:00:00" }.GetHashCode()))));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetNewMortgageSaleActivities_Exception()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<NewLoanSaleActivity, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ThrowsAsync(new Exception("Yikes"));
|
||||
|
||||
Assert.ThrowsAsync<Exception>(async () =>
|
||||
await _activityDao.GetNewMortgageSaleActivities(DateTime.Parse("2020-04-02T11:00:00"), 1));
|
||||
|
||||
//Parameters are passed in using Anonymous Object,Verify they are expected object using HashCode. Obj.Equals has issues with Anonymous Objects.
|
||||
_mockCoreDbExecution.Verify(x =>
|
||||
x.ExecuteQuery<NewLoanSaleActivity, object>(It.Is<string>(str => str.Contains(":newerThanDateTime")),
|
||||
It.Is<object>(obj =>
|
||||
obj.GetHashCode().Equals(new { newerThanDateTime = "2020-04-02 11:00:00", afterActivityNbr = "1" }.GetHashCode()))), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetNewVehicleSaleActivities_OK()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<NewLoanSaleActivity, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ReturnsAsync(new List<NewLoanSaleActivity>()
|
||||
{
|
||||
new NewLoanSaleActivity() { ActivityNbr = 1 },
|
||||
new NewLoanSaleActivity() { ActivityNbr = 2 },
|
||||
new NewLoanSaleActivity() { ActivityNbr = 3 }
|
||||
}).Verifiable();
|
||||
|
||||
var results = await _activityDao.GetNewVehicleSaleActivities(DateTime.Parse("2020-04-02T11:00:00"), 1);
|
||||
|
||||
Assert.NotNull(results);
|
||||
Assert.AreEqual(3, results.Count);
|
||||
//Parameters are passed in using Anonymous Object, Verify they are expected object using HashCode. Obj.Equals has issues with Anonymous Objects.
|
||||
_mockCoreDbExecution.Verify(x =>
|
||||
x.ExecuteQuery<NewLoanSaleActivity, object>(It.Is<string>(str => str.Contains(":newerThanDateTime")),
|
||||
It.Is<object>(obj =>
|
||||
obj.GetHashCode().Equals(new { afterActivityNbr = "1", newerThanDateTime = "2020-04-02 11:00:00" }.GetHashCode()))));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetNewVehicleSaleActivities_Exception()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<NewLoanSaleActivity, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ThrowsAsync(new Exception("Yikes"));
|
||||
|
||||
Assert.ThrowsAsync<Exception>(async () =>
|
||||
await _activityDao.GetNewVehicleSaleActivities(DateTime.Parse("2020-04-02T11:00:00"), 1));
|
||||
|
||||
//Parameters are passed in using Anonymous Object,Verify they are expected object using HashCode. Obj.Equals has issues with Anonymous Objects.
|
||||
_mockCoreDbExecution.Verify(x =>
|
||||
x.ExecuteQuery<NewLoanSaleActivity, object>(It.Is<string>(str => str.Contains(":newerThanDateTime")),
|
||||
It.Is<object>(obj =>
|
||||
obj.GetHashCode().Equals(new { newerThanDateTime = "2020-04-02 11:00:00", afterActivityNbr = "1" }.GetHashCode()))), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetNewEDeliverySaleActivities_OK()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<EStatementDeliveryMethod, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ReturnsAsync(new List<EStatementDeliveryMethod>()
|
||||
{
|
||||
new EStatementDeliveryMethod() { ActivityNumber = 1 },
|
||||
new EStatementDeliveryMethod() { ActivityNumber = 2 },
|
||||
new EStatementDeliveryMethod() { ActivityNumber = 3 }
|
||||
}).Verifiable();
|
||||
|
||||
var results = await _activityDao.GetEStatementDeliveryActivity(DateTime.Parse("2020-04-02T11:00:00"));
|
||||
|
||||
Assert.NotNull(results);
|
||||
Assert.AreEqual(3, results.Count);
|
||||
|
||||
_mockCoreDbExecution.Verify(x =>
|
||||
x.ExecuteQuery<EStatementDeliveryMethod, object>(It.Is<string>(str => str.Contains(":newerThanDateTime")),
|
||||
It.Is<object>(obj =>
|
||||
obj.GetHashCode().Equals(new { newerThanDateTime = "2020-04-02 11:00:00" }.GetHashCode()))));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetNewEDeliverySaleActivities_Exception()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<EStatementDeliveryMethod, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ThrowsAsync(new Exception("Exception thrown"));
|
||||
|
||||
Assert.ThrowsAsync<Exception>(async () =>
|
||||
await _activityDao.GetEStatementDeliveryActivity(null));
|
||||
|
||||
_mockCoreDbExecution.Verify(x =>
|
||||
x.ExecuteQuery<EStatementDeliveryMethod, object>(It.Is<string>(str => str.Contains(":newerThanDateTime")),
|
||||
It.Is<object>(obj =>
|
||||
obj.GetHashCode().Equals(new { newerThanDateTime = "2020-04-02 11:00:00" }.GetHashCode()))), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetNewDebtProtectedLoanSaleActivities_OK()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<NewLoanSaleActivity, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ReturnsAsync(new List<NewLoanSaleActivity>()
|
||||
{
|
||||
new NewLoanSaleActivity() { ActivityNbr = 1 },
|
||||
new NewLoanSaleActivity() { ActivityNbr = 2 },
|
||||
new NewLoanSaleActivity() { ActivityNbr = 3 }
|
||||
}).Verifiable();
|
||||
|
||||
var results = await _activityDao.GetNewDebtProtectedLoanSaleActivities(DateTime.Parse("2020-04-02T11:00:00"), 1);
|
||||
|
||||
Assert.NotNull(results);
|
||||
Assert.AreEqual(3, results.Count);
|
||||
//Parameters are passed in using Anonymous Object, Verify they are expected object using HashCode. Obj.Equals has issues with Anonymous Objects.
|
||||
_mockCoreDbExecution.Verify(x =>
|
||||
x.ExecuteQuery<NewLoanSaleActivity, object>(It.Is<string>(str => str.Contains(":newerThanDateTime")),
|
||||
It.Is<object>(obj =>
|
||||
obj.GetHashCode().Equals(new { afterActivityNbr = "1", newerThanDateTime = "2020-04-02 11:00:00" }.GetHashCode()))));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetNewDebtProtectedLoanSaleActivities_Exception()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<NewLoanSaleActivity, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ThrowsAsync(new Exception("Yikes"));
|
||||
|
||||
Assert.ThrowsAsync<Exception>(async () =>
|
||||
await _activityDao.GetNewDebtProtectedLoanSaleActivities(DateTime.Parse("2020-04-02T11:00:00"), 1));
|
||||
|
||||
//Parameters are passed in using Anonymous Object,Verify they are expected object using HashCode. Obj.Equals has issues with Anonymous Objects.
|
||||
_mockCoreDbExecution.Verify(x =>
|
||||
x.ExecuteQuery<NewLoanSaleActivity, object>(It.Is<string>(str => str.Contains(":newerThanDateTime")),
|
||||
It.Is<object>(obj =>
|
||||
obj.GetHashCode().Equals(new { newerThanDateTime = "2020-04-02 11:00:00", afterActivityNbr = "1" }.GetHashCode()))), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task QueryActivityManagerActivity_OK()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<NewActivityManagerIncentiveReferral, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ReturnsAsync(new List<NewActivityManagerIncentiveReferral>()
|
||||
{
|
||||
new() { ActivityId = 1 },
|
||||
new() { ActivityId = 2 },
|
||||
new() { ActivityId = 3 }
|
||||
}).Verifiable();
|
||||
|
||||
var results = await _activityDao.QueryActivityManagerActivity(new ActivityQueryRequest()
|
||||
{
|
||||
ActivityIds = new List<long>() { 1, 2, 3 }
|
||||
});
|
||||
|
||||
Assert.NotNull(results);
|
||||
Assert.AreEqual(3, results.Count);
|
||||
//Parameters are passed in using Anonymous Object, Verify they are expected object using HashCode. Obj.Equals has issues with Anonymous Objects.
|
||||
_mockCoreDbExecution.Verify(x =>
|
||||
x.ExecuteQuery<NewActivityManagerIncentiveReferral, object>(It.Is<string>(str => str.Contains(":activityIds")), It.IsAny<object>()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task QueryActivityManagerActivity_Exception()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<NewActivityManagerIncentiveReferral, object>(It.IsAny<string>(),
|
||||
It.IsAny<object>()))
|
||||
.ThrowsAsync(new Exception());
|
||||
|
||||
Assert.ThrowsAsync<Exception>(async () =>
|
||||
await _activityDao.QueryActivityManagerActivity(new ActivityQueryRequest()
|
||||
{
|
||||
ActivityIds = new List<long>() { 1, 2, 3 }
|
||||
}));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetPersonActivityByPhoneNumber_OK()
|
||||
{
|
||||
var phoneNumber = Guid.NewGuid().ToString();
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<PersonRecentActivity, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ReturnsAsync(new List<PersonRecentActivity>()
|
||||
{
|
||||
new() { PersonNumber = DateTime.Now.Millisecond, HomePhone = phoneNumber }
|
||||
}).Verifiable();
|
||||
|
||||
var result = await _activityDao.GetPersonActivityByPhoneNumber(phoneNumber);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(phoneNumber, result.FirstOrDefault()?.HomePhone);
|
||||
_mockCoreDbExecution.Verify();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetPersonActivityByPhoneNumber_Exception()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<PersonRecentActivity, object>(It.IsAny<string>(),
|
||||
It.IsAny<object>()))
|
||||
.ThrowsAsync(new Exception());
|
||||
|
||||
Assert.ThrowsAsync<Exception>(async () =>
|
||||
await _activityDao.GetPersonActivityByPhoneNumber(It.IsAny<string>()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetPersonActivityByPersonNumber_OK()
|
||||
{
|
||||
var personNumber = DateTime.Now.Millisecond;
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<PersonRecentActivity, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ReturnsAsync(new List<PersonRecentActivity>
|
||||
{
|
||||
new() { PersonNumber = personNumber }
|
||||
}).Verifiable();
|
||||
|
||||
var result = await _activityDao.GetPersonActivityByPersonNumber(personNumber.ToString());
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(personNumber, result.PersonNumber);
|
||||
_mockCoreDbExecution.Verify();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetPersonActivityByPersonNumber_Exception()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<PersonRecentActivity, object>(It.IsAny<string>(),
|
||||
It.IsAny<object>()))
|
||||
.ThrowsAsync(new Exception());
|
||||
|
||||
Assert.ThrowsAsync<Exception>(async () =>
|
||||
await _activityDao.GetPersonActivityByPersonNumber(It.IsAny<string>()));
|
||||
}
|
||||
}
|
||||
}
|
||||
+127
@@ -0,0 +1,127 @@
|
||||
using LCU.Library.Internal.CoreApiWrapperLib.CoreDbUtilities;
|
||||
using LCU.Library.Internal.CoreApiWrapperLib.DataAccess;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.MemberAgreements;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LCU.Api.Internal.CoreApiWrapperTest.DataAccess
|
||||
{
|
||||
public class AgreeDaoTest
|
||||
{
|
||||
private AgreeDao _agreeDao;
|
||||
private Mock<ICoreDbExecution> _mockCoreDbExecution;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
_mockCoreDbExecution = new Mock<ICoreDbExecution>();
|
||||
_agreeDao = new AgreeDao(_mockCoreDbExecution.Object);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task FindAgreeUsersByAccountNumbers_OK()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<AgreeUserAccount, object>(It.IsAny<string>(),
|
||||
It.IsAny<Dictionary<string, object>>()))
|
||||
.ReturnsAsync(new List<AgreeUserAccount>()
|
||||
{
|
||||
new()
|
||||
{
|
||||
AccountNumber = 20001,
|
||||
AgreeNumber = 2000,
|
||||
UserId = "12000"
|
||||
}
|
||||
}).Verifiable();
|
||||
|
||||
var testAccountNumbers = new List<string>() { "20001" };
|
||||
var results = await _agreeDao.FindAgreeUsersByAccountNumbers(testAccountNumbers);
|
||||
|
||||
Assert.NotNull(results);
|
||||
var firstResult = results.FirstOrDefault();
|
||||
Assert.AreEqual(20001, firstResult.AccountNumber);
|
||||
Assert.AreEqual(2000, firstResult.AgreeNumber);
|
||||
Assert.AreEqual("12000", firstResult.UserId);
|
||||
|
||||
_mockCoreDbExecution.Verify(x =>
|
||||
x.ExecuteQuery<AgreeUserAccount, Dictionary<string, object>>(
|
||||
It.Is<string>(str => str.Contains(":param0")),
|
||||
It.IsAny<Dictionary<string, object>>()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FindByUserId_Exception()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<AgreeUserAccount, object>(It.IsAny<string>(),
|
||||
It.IsAny<Dictionary<string, object>>()))
|
||||
.ThrowsAsync(new Exception("Ah oh Error"));
|
||||
|
||||
|
||||
var testAccountNumbers = new List<string>() { "20001" };
|
||||
Assert.ThrowsAsync<Exception>(async () =>
|
||||
await _agreeDao.FindAgreeUsersByAccountNumbers(testAccountNumbers));
|
||||
|
||||
_mockCoreDbExecution.Verify(x =>
|
||||
x.ExecuteQuery<AgreeUserAccount, Dictionary<string, object>>(
|
||||
It.Is<string>(str => str.Contains(":param0")),
|
||||
It.IsAny<Dictionary<string, object>>()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task FindAgreeUserByPersonNumber_OK()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<string, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ReturnsAsync(new List<string> { "5436" }).Verifiable();
|
||||
|
||||
var result = await _agreeDao.FindAgreeUserByPersonNumber(12355L);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual("5436", result.FirstOrDefault());
|
||||
_mockCoreDbExecution.Verify();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FindAgreeUserByPersonNumber_Exception()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<string, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ThrowsAsync(new Exception("Error thrown from unit test"));
|
||||
|
||||
Assert.ThrowsAsync<Exception>(async () => await _agreeDao.FindAgreeUserByPersonNumber(123L));
|
||||
|
||||
_mockCoreDbExecution.Verify();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task FindAgreeUserByOrganizationNumber_OK()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<string, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ReturnsAsync(new List<string> { "5436" }).Verifiable();
|
||||
|
||||
var result = await _agreeDao.FindAgreeUserByOrganizationNumber(12355L);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual("5436", result);
|
||||
_mockCoreDbExecution.Verify();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FindAgreeUserByOrganizationNumber_Exception()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<string, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ThrowsAsync(new Exception("Error thrown from unit test"));
|
||||
|
||||
Assert.ThrowsAsync<Exception>(async () => await _agreeDao.FindAgreeUserByOrganizationNumber(123L));
|
||||
|
||||
_mockCoreDbExecution.Verify();
|
||||
}
|
||||
}
|
||||
}
|
||||
+174
@@ -0,0 +1,174 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using LCU.Library.Internal.ApiSecurity.Models;
|
||||
using LCU.Library.Internal.CoreApiWrapperLib.Configuration;
|
||||
using LCU.Library.Internal.CoreApiWrapperLib.CoreDbUtilities;
|
||||
using LCU.Library.Internal.CoreApiWrapperLib.DataAccess;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.MemberAgreements;
|
||||
using LCU.Library.Internal.LcuHttpClient.HttpRequest;
|
||||
|
||||
namespace LCU.Api.Internal.CoreApiWrapperTest.DataAccess
|
||||
{
|
||||
public class AgreePersonDaoTest
|
||||
{
|
||||
private AgreePersonDao _agreePersonDao;
|
||||
private Mock<ICoreDbExecution> _mockCoreDbExecution;
|
||||
private ApiSecurityConfiguration _apiSecurityConfiguration;
|
||||
private Mock<IPutRequest> _mockPutRequest;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
_mockCoreDbExecution = new Mock<ICoreDbExecution>();
|
||||
_mockPutRequest = new Mock<IPutRequest>();
|
||||
|
||||
var coreConfiguration = new CoreConfiguration()
|
||||
{
|
||||
CoreSoapApiConfiguration = new CoreSoapApiConfiguration()
|
||||
{
|
||||
CoreSoapApiWrapperHost = "test.lcu-internal.com",
|
||||
CoreSoapEndpointConfiguration = new CoreSoapEndpointConfiguration()
|
||||
{
|
||||
PutPersonAgreementsDetailTypes = "api/Test/core/PutThing"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
_apiSecurityConfiguration = new ApiSecurityConfiguration()
|
||||
{
|
||||
InternalApiKeySet = new Dictionary<string, string>()
|
||||
{
|
||||
["CoreSoapApiWrapper"] = "TEST"
|
||||
}
|
||||
};
|
||||
|
||||
_agreePersonDao = new AgreePersonDao(_mockCoreDbExecution.Object,
|
||||
coreConfiguration,
|
||||
_apiSecurityConfiguration,
|
||||
_mockPutRequest.Object);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task FindByUserId_OK()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<AgreePerson, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ReturnsAsync(new List<AgreePerson>()
|
||||
{
|
||||
new AgreePerson()
|
||||
{
|
||||
AgreeNumber = 100,
|
||||
PersonNumber = 10,
|
||||
UserId = "1"
|
||||
}
|
||||
}).Verifiable();
|
||||
|
||||
var result = await _agreePersonDao.FindByUserId("1");
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(100, result.AgreeNumber);
|
||||
Assert.AreEqual(10, result.PersonNumber);
|
||||
Assert.AreEqual("1", result.UserId);
|
||||
//Parameters are passed in using Anonymous Object,
|
||||
// Verify they are expected object using HashCode. Obj.Equals has issues with Anonymous Objects.
|
||||
_mockCoreDbExecution.Verify(x =>
|
||||
x.ExecuteQuery<AgreePerson, object>(It.Is<string>(str => str.Contains(":userId")),
|
||||
It.Is<object>(obj => obj.GetHashCode().Equals(new { userId = "1"}.GetHashCode()))));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FindByUserId_Exception()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<AgreePerson, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ThrowsAsync(new Exception("Ah oh Error"));
|
||||
|
||||
Assert.ThrowsAsync<Exception>(async () =>
|
||||
await _agreePersonDao.FindByUserId("1"));
|
||||
|
||||
//Parameters are passed in using Anonymous Object,
|
||||
// Verify they are expected object using HashCode. Obj.Equals has issues with Anonymous Objects.
|
||||
_mockCoreDbExecution.Verify(x =>
|
||||
x.ExecuteQuery<AgreePerson, object>(It.Is<string>(str => str.Contains(":userId")),
|
||||
It.Is<object>(obj => obj.GetHashCode().Equals(new { userId = "1"}.GetHashCode()))));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task FindAgreePersonsWithHyphenatedUserId_OK()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<AgreePerson>(It.IsAny<string>()))
|
||||
.ReturnsAsync(new List<AgreePerson>()
|
||||
{
|
||||
new AgreePerson()
|
||||
{
|
||||
AgreeNumber = 100,
|
||||
PersonNumber = 10,
|
||||
UserId = "1-1"
|
||||
}
|
||||
}).Verifiable();
|
||||
|
||||
var result = await _agreePersonDao.FindAgreePersonsWithHyphenatedUserId();
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(1, result.Count());
|
||||
var singleResult = result.FirstOrDefault();
|
||||
Assert.NotNull(singleResult);
|
||||
Assert.AreEqual(100, singleResult.AgreeNumber);
|
||||
Assert.AreEqual(10, singleResult.PersonNumber);
|
||||
Assert.AreEqual("1-1", singleResult.UserId);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FindAgreePersonsWithHyphenatedUserId_Exception()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<AgreePerson>(It.IsAny<string>()))
|
||||
.ThrowsAsync(new Exception("Ah oh Error"));
|
||||
|
||||
Assert.ThrowsAsync<Exception>(async () =>
|
||||
await _agreePersonDao.FindAgreePersonsWithHyphenatedUserId());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task FindActiveCustodialVruCardAgreementAgreePersons_OK()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<AgreePerson>(It.IsAny<string>()))
|
||||
.ReturnsAsync(new List<AgreePerson>()
|
||||
{
|
||||
new AgreePerson()
|
||||
{
|
||||
AgreeNumber = 100,
|
||||
PersonNumber = 10,
|
||||
UserId = "11"
|
||||
}
|
||||
}).Verifiable();
|
||||
|
||||
var result = await _agreePersonDao.FindActiveCustodialVruCardAgreementAgreePersons();
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(1, result.Count());
|
||||
var singleResult = result.FirstOrDefault();
|
||||
Assert.NotNull(singleResult);
|
||||
Assert.AreEqual(100, singleResult.AgreeNumber);
|
||||
Assert.AreEqual(10, singleResult.PersonNumber);
|
||||
Assert.AreEqual("11", singleResult.UserId);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FindActiveCustodialVruCardAgreementAgreePersons_Exception()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<AgreePerson>(It.IsAny<string>()))
|
||||
.ThrowsAsync(new Exception("Ah oh Error"));
|
||||
|
||||
Assert.ThrowsAsync<Exception>(async () =>
|
||||
await _agreePersonDao.FindActiveCustodialVruCardAgreementAgreePersons());
|
||||
}
|
||||
}
|
||||
}
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using LCU.Library.Internal.CoreApiWrapperLib.CoreDbUtilities;
|
||||
using LCU.Library.Internal.CoreApiWrapperLib.DataAccess;
|
||||
using System.Linq;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.ApplicationHistories;
|
||||
|
||||
namespace LCU.Api.Internal.CoreApiWrapperTest.DataAccess
|
||||
{
|
||||
public class ApplicationHistoryDaoTest
|
||||
{
|
||||
private ApplicationHistoryDao _applicationHistoryDao;
|
||||
private Mock<ICoreDbExecution> _mockCoreDbExecution;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
_mockCoreDbExecution = new Mock<ICoreDbExecution>();
|
||||
_applicationHistoryDao = new ApplicationHistoryDao(_mockCoreDbExecution.Object);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task FindApplicationHistory_OK()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<ApplicationHistory, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ReturnsAsync(new List<ApplicationHistory>()
|
||||
{
|
||||
new ApplicationHistory()
|
||||
{
|
||||
ApplicationName = "Test",
|
||||
ApplicationNumber = 1,
|
||||
QueueNumber = 10,
|
||||
StopDateTime = Convert.ToDateTime("1/1/2021"),
|
||||
EffectiveDate = Convert.ToDateTime("1/1/2021")
|
||||
},
|
||||
new ApplicationHistory()
|
||||
{
|
||||
ApplicationName = "Test2",
|
||||
ApplicationNumber = 2,
|
||||
QueueNumber = 20,
|
||||
StopDateTime = Convert.ToDateTime("1/1/2021"),
|
||||
EffectiveDate = Convert.ToDateTime("1/1/2021")
|
||||
}
|
||||
}).Verifiable();
|
||||
|
||||
var applicationTestNumbers = new List<string>()
|
||||
{
|
||||
"1",
|
||||
"2"
|
||||
};
|
||||
var effectiveDate = Convert.ToDateTime("1/2/2021");
|
||||
var results = await _applicationHistoryDao.FindApplicationHistory(applicationTestNumbers, effectiveDate);
|
||||
|
||||
var resultsList = results.ToList();
|
||||
Assert.NotNull(results);
|
||||
Assert.AreEqual(2, resultsList.Count);
|
||||
Assert.True(resultsList.Any(x => x.ApplicationName == "Test"));
|
||||
Assert.True(resultsList.Any(x => x.ApplicationName == "Test"));
|
||||
Assert.True(resultsList.Any(x => x.ApplicationNumber == 1));
|
||||
Assert.True(resultsList.Any(x => x.ApplicationNumber == 2));
|
||||
Assert.True(resultsList.Any(x => x.QueueNumber == 10));
|
||||
Assert.True(resultsList.Any(x => x.QueueNumber == 20));
|
||||
Assert.True(resultsList.Any(x => x.StopDateTime == Convert.ToDateTime("1/1/2021")));
|
||||
Assert.True(resultsList.Any(x => x.EffectiveDate == Convert.ToDateTime("1/1/2021")));
|
||||
Assert.AreEqual(2, resultsList.Where(r => r.StopDateTime == Convert.ToDateTime("1/1/2021")).ToList().Count);
|
||||
|
||||
_mockCoreDbExecution.Verify(x =>
|
||||
x.ExecuteQuery<ApplicationHistory, object>(
|
||||
It.Is<string>(str => str.Contains(":param0") && str.Contains(":param1") &&
|
||||
str.Contains(":EffectiveDate")),
|
||||
It.IsAny<object>()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FindApplicationHistory_Exception()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<ApplicationHistory, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ThrowsAsync(new Exception("Ah oh Error"));
|
||||
|
||||
var applicationTestNumbers = new List<string>()
|
||||
{
|
||||
"1",
|
||||
"2"
|
||||
};
|
||||
var effectiveDate = Convert.ToDateTime("1/2/2021");
|
||||
|
||||
Assert.ThrowsAsync<Exception>(async () =>
|
||||
await _applicationHistoryDao.FindApplicationHistory(applicationTestNumbers, effectiveDate));
|
||||
|
||||
_mockCoreDbExecution.Verify(x =>
|
||||
x.ExecuteQuery<ApplicationHistory, object>(
|
||||
It.Is<string>(str => str.Contains(":param0") && str.Contains(":param1") &&
|
||||
str.Contains(":EffectiveDate")),
|
||||
It.IsAny<object>()));
|
||||
}
|
||||
}
|
||||
}
|
||||
+275
@@ -0,0 +1,275 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using LCU.Library.Internal.ApiSecurity.Models;
|
||||
using LCU.Library.Internal.CoreApiWrapperLib.Configuration;
|
||||
using LCU.Library.Internal.CoreApiWrapperLib.CoreDbUtilities;
|
||||
using LCU.Library.Internal.CoreApiWrapperLib.DataAccess;
|
||||
using LCU.Library.Internal.CoreApiWrapperLib.Utilities;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.IndirectLoan;
|
||||
using LCU.Library.Internal.LcuHttpClient.HttpRequest;
|
||||
|
||||
namespace LCU.Api.Internal.CoreApiWrapperTest.DataAccess
|
||||
{
|
||||
public class IndirectLoanDaoTest
|
||||
{
|
||||
private IndirectLoanDao _indirectLoanDao;
|
||||
private Mock<ICoreDbExecution> _mockCoreDbExecution;
|
||||
private CoreConfiguration _coreConfiguration;
|
||||
private ApiSecurityConfiguration _apiSecurityConfiguration;
|
||||
private Mock<IPutRequest> _mockPutRequest;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
_mockPutRequest = new Mock<IPutRequest>();
|
||||
|
||||
_coreConfiguration = new CoreConfiguration()
|
||||
{
|
||||
CoreSoapApiConfiguration = new CoreSoapApiConfiguration()
|
||||
{
|
||||
CoreSoapEndpointConfiguration = new CoreSoapEndpointConfiguration()
|
||||
{
|
||||
PutDealerOriginalBalance = "TEST/IndirectLoan/PutDealerOriginalBalance"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
_apiSecurityConfiguration = new ApiSecurityConfiguration()
|
||||
{
|
||||
InternalApiKeySet = new Dictionary<string, string>()
|
||||
{
|
||||
["CoreSoapApiWrapper"] = "TEST"
|
||||
}
|
||||
};
|
||||
|
||||
_mockCoreDbExecution = new Mock<ICoreDbExecution>();
|
||||
_indirectLoanDao = new IndirectLoanDao(_mockCoreDbExecution.Object,
|
||||
_coreConfiguration,
|
||||
_apiSecurityConfiguration,
|
||||
_mockPutRequest.Object);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetIndirectLoanByAccountNumber_OK()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<IndirectLoanDetail, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ReturnsAsync(new List<IndirectLoanDetail>()
|
||||
{
|
||||
new IndirectLoanDetail() {LoanNumber = "1234"}
|
||||
}).Verifiable();
|
||||
|
||||
var results = await _indirectLoanDao.FindByAccountNumber(1234);
|
||||
|
||||
Assert.NotNull(results);
|
||||
Assert.AreEqual(1, results.Count());
|
||||
_mockCoreDbExecution.Verify(x =>
|
||||
x.ExecuteQuery<IndirectLoanDetail, object>(It.Is<string>(str => str.Contains(":AcctNbr")),
|
||||
It.Is<object>(obj =>
|
||||
obj.GetHashCode().Equals(new { AcctNbr = 1234 }.GetHashCode()))));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetIndirectLoanByAccountNumber_Exception()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<IndirectLoanDetail, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ThrowsAsync(new Exception("Yikes"));
|
||||
|
||||
Assert.ThrowsAsync<Exception>(async () =>
|
||||
await _indirectLoanDao.FindByAccountNumber(1234));
|
||||
|
||||
_mockCoreDbExecution.Verify(x =>
|
||||
x.ExecuteQuery<IndirectLoanDetail, object>(It.Is<string>(str => str.Contains(":AcctNbr")),
|
||||
It.Is<object>(obj =>
|
||||
obj.GetHashCode().Equals(new { AcctNbr = 1234 }.GetHashCode()))));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetIndirectLoansByPostedDate_OK()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<IndirectLoanDetail, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ReturnsAsync(new List<IndirectLoanDetail>()
|
||||
{
|
||||
new IndirectLoanDetail { LoanNumber = "1" },
|
||||
new IndirectLoanDetail { LoanNumber = "2" },
|
||||
new IndirectLoanDetail { LoanNumber = "3" }
|
||||
}).Verifiable();
|
||||
|
||||
var results = await _indirectLoanDao.FindByPostedDate(DateTime.Parse("2021-05-01T11:00:00"));
|
||||
|
||||
Assert.NotNull(results);
|
||||
Assert.AreEqual(3, results.Count());
|
||||
_mockCoreDbExecution.Verify(x =>
|
||||
x.ExecuteQuery<IndirectLoanDetail, object>(It.Is<string>(str => str.Contains(":newerThanDateTime")),
|
||||
It.Is<object>(obj =>
|
||||
obj.GetHashCode().Equals(new { newerThanDateTime = "2021-05-01 11:00:00" }.GetHashCode()))));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetIndirectLoansByPostedDate_Exception()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<IndirectLoanDetail, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ThrowsAsync(new Exception("Yikes"));
|
||||
|
||||
Assert.ThrowsAsync<Exception>(async () =>
|
||||
await _indirectLoanDao.FindByPostedDate(DateTime.Parse("2021-05-01T11:00:00")));
|
||||
|
||||
//Parameters are passed in using Anonymous Object,Verify they are expected object using HashCode. Obj.Equals has issues with Anonymous Objects.
|
||||
_mockCoreDbExecution.Verify(x =>
|
||||
x.ExecuteQuery<IndirectLoanDetail, object>(It.Is<string>(str => str.Contains(":newerThanDateTime")),
|
||||
It.Is<object>(obj =>
|
||||
obj.GetHashCode().Equals(new { newerThanDateTime = "2021-05-01 11:00:00" }.GetHashCode()))));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetClosedIndirectLoansByPostedDate_OK()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<ClosedIndirectLoan, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ReturnsAsync(new List<ClosedIndirectLoan>()
|
||||
{
|
||||
new ClosedIndirectLoan { LoanNumber = "1" },
|
||||
new ClosedIndirectLoan { LoanNumber = "2" },
|
||||
new ClosedIndirectLoan { LoanNumber = "3" }
|
||||
}).Verifiable();
|
||||
|
||||
var results = await _indirectLoanDao.FindClosedByPostedDate(DateTime.Parse("2021-05-01T11:00:00"));
|
||||
|
||||
Assert.NotNull(results);
|
||||
Assert.AreEqual(3, results.Count());
|
||||
_mockCoreDbExecution.Verify(x =>
|
||||
x.ExecuteQuery<ClosedIndirectLoan, object>(It.Is<string>(str => str.Contains(":newerThanDateTime") && str.Contains("CLS")),
|
||||
It.Is<object>(obj =>
|
||||
obj.GetHashCode().Equals(new { newerThanDateTime = "2021-05-01 11:00:00" }.GetHashCode()))));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetClosedIndirectLoansByPostedDate_Exception()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<ClosedIndirectLoan, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ThrowsAsync(new Exception("Yikes"));
|
||||
|
||||
Assert.ThrowsAsync<Exception>(async () =>
|
||||
await _indirectLoanDao.FindClosedByPostedDate(DateTime.Parse("2021-05-01T11:00:00")));
|
||||
|
||||
//Parameters are passed in using Anonymous Object,Verify they are expected object using HashCode. Obj.Equals has issues with Anonymous Objects.
|
||||
_mockCoreDbExecution.Verify(x =>
|
||||
x.ExecuteQuery<ClosedIndirectLoan, object>(It.Is<string>(str => str.Contains(":newerThanDateTime") && str.Contains("CLS")),
|
||||
It.Is<object>(obj =>
|
||||
obj.GetHashCode().Equals(new { newerThanDateTime = "2021-05-01 11:00:00" }.GetHashCode()))));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetClosedIndirectLoansWithDetailByPostedDate_OK()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<IndirectLoanDetail, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ReturnsAsync(new List<IndirectLoanDetail>()
|
||||
{
|
||||
new IndirectLoanDetail { LoanNumber = "1" },
|
||||
new IndirectLoanDetail { LoanNumber = "2" },
|
||||
new IndirectLoanDetail { LoanNumber = "3" }
|
||||
}).Verifiable();
|
||||
|
||||
var results = await _indirectLoanDao.FindClosedWithDetailByPostedDate(DateTime.Parse("2021-05-01T11:00:00"));
|
||||
|
||||
Assert.NotNull(results);
|
||||
Assert.AreEqual(3, results.Count());
|
||||
_mockCoreDbExecution.Verify(x =>
|
||||
x.ExecuteQuery<IndirectLoanDetail, object>(It.Is<string>(str => str.Contains(":newerThanDateTime") && str.Contains("CLS")),
|
||||
It.Is<object>(obj =>
|
||||
obj.GetHashCode().Equals(new { newerThanDateTime = "2021-05-01 11:00:00" }.GetHashCode()))));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetClosedIndirectLoansWithDetailByPostedDate_Exception()
|
||||
{
|
||||
_mockCoreDbExecution
|
||||
.Setup(x => x.ExecuteQuery<IndirectLoanDetail, object>(It.IsAny<string>(), It.IsAny<object>()))
|
||||
.ThrowsAsync(new Exception("Yikes"));
|
||||
|
||||
Assert.ThrowsAsync<Exception>(async () =>
|
||||
await _indirectLoanDao.FindClosedWithDetailByPostedDate(DateTime.Parse("2021-05-01T11:00:00")));
|
||||
|
||||
//Parameters are passed in using Anonymous Object,Verify they are expected object using HashCode. Obj.Equals has issues with Anonymous Objects.
|
||||
_mockCoreDbExecution.Verify(x =>
|
||||
x.ExecuteQuery<IndirectLoanDetail, object>(It.Is<string>(str => str.Contains(":newerThanDateTime") && str.Contains("CLS")),
|
||||
It.Is<object>(obj =>
|
||||
obj.GetHashCode().Equals(new { newerThanDateTime = "2021-05-01 11:00:00" }.GetHashCode()))));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task UpdateDealerOriginalBalance_Ok()
|
||||
{
|
||||
var accountNumber = "111111111111";
|
||||
var response = new UpdateDealerOriginalBalanceResponse();
|
||||
var responseList = new List<UpdateDealerOriginalBalanceResponse> { response }; //no errors in response
|
||||
var endpoint = HttpUtilities.BuildHttpsUri(_coreConfiguration.CoreSoapApiConfiguration.CoreSoapApiWrapperHost,
|
||||
_coreConfiguration.CoreSoapApiConfiguration.CoreSoapEndpointConfiguration.PutDealerOriginalBalance + $"?accountNumber={accountNumber}");
|
||||
_mockPutRequest.Setup(x => x.Async<string, List<UpdateDealerOriginalBalanceResponse>>(endpoint,
|
||||
null,
|
||||
It.IsAny<Dictionary<string, string>>(),
|
||||
It.IsAny<int>(),
|
||||
It.IsAny<int>()))
|
||||
.ReturnsAsync(responseList).Verifiable();
|
||||
|
||||
var results = await _indirectLoanDao.UpdateDealerOriginalBalance(accountNumber);
|
||||
Assert.IsNotNull(results);
|
||||
Assert.AreEqual("", results.ToList().Where(x => x.AccountNumber == "111111111111"));
|
||||
_mockPutRequest.Verify();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task UpdateDealerOriginalBalance_Ok_WithErrors()
|
||||
{
|
||||
var accountNumber ="111111111111";
|
||||
var response = new UpdateDealerOriginalBalanceResponse()
|
||||
{
|
||||
AccountNumber = "111111111111",
|
||||
ErrorMessage = "Error: This account is not valid for update."
|
||||
};
|
||||
|
||||
var responseList = new List<UpdateDealerOriginalBalanceResponse> { response }; //error for second account
|
||||
var endpoint = HttpUtilities.BuildHttpsUri(_coreConfiguration.CoreSoapApiConfiguration.CoreSoapApiWrapperHost,
|
||||
_coreConfiguration.CoreSoapApiConfiguration.CoreSoapEndpointConfiguration.PutDealerOriginalBalance + $"?accountNumber={accountNumber}");
|
||||
_mockPutRequest.Setup(x => x.Async<string, List<UpdateDealerOriginalBalanceResponse>>(endpoint,
|
||||
null,
|
||||
It.IsAny<Dictionary<string, string>>(),
|
||||
It.IsAny<int>(),
|
||||
It.IsAny<int>()))
|
||||
.ReturnsAsync(responseList).Verifiable();
|
||||
|
||||
var results = await _indirectLoanDao.UpdateDealerOriginalBalance(accountNumber);
|
||||
Assert.IsNotNull(results);
|
||||
Assert.AreEqual(1, results.Count());
|
||||
Assert.AreEqual("111111111111", results.ToList().Where(x => x.AccountNumber == "111111111111").FirstOrDefault().AccountNumber);
|
||||
_mockPutRequest.Verify();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UpdateDealerOriginalBalance_Exception()
|
||||
{
|
||||
var accountNumber = "111111111111";
|
||||
var endpoint = HttpUtilities.BuildHttpsUri(_coreConfiguration.CoreSoapApiConfiguration.CoreSoapApiWrapperHost,
|
||||
_coreConfiguration.CoreSoapApiConfiguration.CoreSoapEndpointConfiguration.PutDealerOriginalBalance + $"?accountNumber={accountNumber}");
|
||||
_mockPutRequest.Setup(x => x.Async<string, List<UpdateDealerOriginalBalanceResponse>>(endpoint,
|
||||
null,
|
||||
It.IsAny<Dictionary<string, string>>(),
|
||||
It.IsAny<int>(),
|
||||
It.IsAny<int>()))
|
||||
.Throws(new Exception("Error thrown in unit test.")).Verifiable();
|
||||
|
||||
Assert.ThrowsAsync<Exception>(async () => await _indirectLoanDao.UpdateDealerOriginalBalance(accountNumber));
|
||||
_mockPutRequest.Verify();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+143
@@ -0,0 +1,143 @@
|
||||
using LCU.Library.Internal.CoreApiWrapperLib.Configuration;
|
||||
using LCU.Library.Internal.CoreApiWrapperLib.CoreApiUtilities;
|
||||
using LCU.Library.Internal.CoreApiWrapperLib.CoreDbUtilities;
|
||||
using LCU.Library.Internal.CoreApiWrapperLib.DataAccess;
|
||||
using LCU.Library.Internal.CoreApiWrapperLib.Utilities;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.Constants;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreRequests;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Organizations;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.PostalAddresses;
|
||||
using Moq;
|
||||
using Newtonsoft.Json;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LCU.Api.Internal.CoreApiWrapperTest.DataAccess
|
||||
{
|
||||
public class OrganizationDaoTest
|
||||
{
|
||||
private readonly OrganizationDao _organizationDao;
|
||||
private readonly Mock<ICoreRequest> _mockCoreRequest;
|
||||
private readonly Mock<ICoreDbExecution> _coreDb;
|
||||
|
||||
public OrganizationDaoTest()
|
||||
{
|
||||
_mockCoreRequest = new Mock<ICoreRequest>();
|
||||
_coreDb = new Mock<ICoreDbExecution>();
|
||||
|
||||
var coreConfiguration = new CoreConfiguration
|
||||
{
|
||||
CoreApiConfiguration = new CoreApiConfiguration
|
||||
{
|
||||
CoreEndPointConfiguration = new CoreEndPointConfiguration
|
||||
{
|
||||
PersonsQueryName = "Test"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
_organizationDao = new OrganizationDao
|
||||
(
|
||||
_mockCoreRequest.Object,
|
||||
coreConfiguration,
|
||||
_coreDb.Object
|
||||
);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task FindOrganizationByMemberAgreeNbr()
|
||||
{
|
||||
// Arrange
|
||||
var listOfIncludes = new List<string>
|
||||
{
|
||||
RequestIncludeConstants.AllAddresses
|
||||
};
|
||||
var coreRequestParameters = new CoreRequestParameters(listOfIncludes);
|
||||
var organizationRequest = new MemberNbrRequest
|
||||
{
|
||||
MemberNbr = 100,
|
||||
};
|
||||
|
||||
var testPostalAddress = new PostalAddress
|
||||
{
|
||||
AddressUseCode = AddressConstants.PrimaryUseCode,
|
||||
AddressNumber = 11,
|
||||
AddressLine1 = "Test Street",
|
||||
AddressLine2 = "",
|
||||
AddressLine3 = "",
|
||||
CityName = "City Test",
|
||||
PostalCode = "53183",
|
||||
ZipPlus = "3123",
|
||||
CountrySubdivisionCode = "WI"
|
||||
};
|
||||
var testPostalAddressList = new List<PostalAddress> { testPostalAddress };
|
||||
var testOrganization = new Organization
|
||||
{
|
||||
MemberAgreementNumber = 111111111,
|
||||
Name = "Test Organization Name",
|
||||
OrganizationNumber = 123,
|
||||
PostalAddressList = testPostalAddressList
|
||||
};
|
||||
|
||||
var header = new CoreMessageHeader();
|
||||
CoreApiMessage<Organization> organizationApiMessage =
|
||||
new CoreApiMessage<Organization>(header, testOrganization);
|
||||
|
||||
var organizationJson = JsonConvert.SerializeObject(testOrganization);
|
||||
|
||||
_mockCoreRequest.Setup(x => x.PostRequestObject<CoreApiMessage<Organization>>(It.IsAny<string>(),
|
||||
It.IsAny<Dictionary<string, string>>(),
|
||||
It.IsAny<string>())).ReturnsAsync(organizationApiMessage);
|
||||
|
||||
// Act
|
||||
var results = _organizationDao.FindOrganizationByMemberAgreeNbr(coreRequestParameters, organizationRequest);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(results);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task FindOrganizationNumbersByNameSearch_AllCases_ExecutesOrganizationNumberByNameLikeQueryWithNameAndLimitParameters()
|
||||
{
|
||||
var query = QueryUtilities.GetQuery("Organization/OrganizationNumberByNameLikeQuery");
|
||||
var name = Guid.NewGuid().ToString().ToUpperInvariant();
|
||||
var limit = DateTime.Now.Millisecond;
|
||||
var resultSeries = new Random(DateTime.Now.Millisecond);
|
||||
var results = new long[]{ resultSeries.Next(), resultSeries.Next(), resultSeries.Next() };
|
||||
_coreDb
|
||||
.Setup(c => c.ExecuteQuery<long, dynamic>(query, It.Is<object>(q => q.GetPropertyValue<string>("organizationName") == name.ToLowerInvariant() && q.GetPropertyValue<int>("limit") == limit)))
|
||||
.Returns(Task.FromResult<IEnumerable<long>>(results));
|
||||
|
||||
var organizationNumbers = await _organizationDao.FindOrganizationNumbersByNameSearch(name, limit);
|
||||
|
||||
Assert.AreSame(results, organizationNumbers);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CountOrganizationNumbersByName_AllCases_ExecutesOrganizationByNameLikeCountWithNameParameter()
|
||||
{
|
||||
var query = QueryUtilities.GetQuery("Organization/OrganizationByNameLikeCount");
|
||||
var name = Guid.NewGuid().ToString().ToUpperInvariant();
|
||||
var count = DateTime.Now.Millisecond;
|
||||
var results = new long[]{ count };
|
||||
_coreDb
|
||||
.Setup(c => c.ExecuteQuery<long, dynamic>(query, It.Is<object>(q => q.GetPropertyValue<string>("organizationName") == name.ToLowerInvariant())))
|
||||
.Returns(Task.FromResult<IEnumerable<long>>(results));
|
||||
|
||||
var organizationCount = await _organizationDao.CountOrganizationNumbersByName(name);
|
||||
|
||||
Assert.AreEqual(count, organizationCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class ObjectPropertyExtension
|
||||
{
|
||||
public static T GetPropertyValue<T>(this object obj, string propertyName)
|
||||
{
|
||||
return (T) obj.GetType().GetProperty(propertyName).GetValue(obj, null);
|
||||
}
|
||||
}
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using Moq;
|
||||
using LCU.Library.Internal.CoreApiWrapperLib.DataAccess;
|
||||
using LCU.Library.Internal.CoreApiWrapperLib.CoreApiUtilities;
|
||||
using LCU.Library.Internal.CoreApiWrapperLib.CoreDbUtilities;
|
||||
using LCU.Library.Internal.CoreApiWrapperLib.Configuration;
|
||||
using LCU.Library.Internal.CoreApiWrapperLib.Utilities;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Persons;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreRequests;
|
||||
|
||||
namespace LCU.Api.Internal.CoreApiWrapperTest.DataAccess
|
||||
{
|
||||
public class PersonDaoTest
|
||||
{
|
||||
private readonly PersonDao _personDao;
|
||||
private readonly Mock<ICoreRequest> _mockCoreRequest;
|
||||
private readonly Mock<ICoreDbExecution> _mockCoreDbExecution;
|
||||
|
||||
public PersonDaoTest()
|
||||
{
|
||||
_mockCoreDbExecution = new Mock<ICoreDbExecution>();
|
||||
_mockCoreRequest = new Mock<ICoreRequest>();
|
||||
|
||||
var coreConfiguration = new CoreConfiguration
|
||||
{
|
||||
CoreApiConfiguration = new CoreApiConfiguration
|
||||
{
|
||||
CoreEndPointConfiguration = new CoreEndPointConfiguration
|
||||
{
|
||||
PersonsQueryName = "Test"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
_personDao = new PersonDao(_mockCoreRequest.Object,
|
||||
_mockCoreDbExecution.Object,
|
||||
coreConfiguration);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task FindPersons_Returns_Null()
|
||||
{
|
||||
var coreRequestParameters = new CoreRequestParameters();
|
||||
var personRequest = new PersonNameRequest();
|
||||
CoreApiMessage<IEnumerable<Person>> personsJsonResponse = null;
|
||||
|
||||
_mockCoreRequest.Setup(x => x.PostRequestObject<CoreApiMessage<IEnumerable<Person>>>(It.IsAny<string>(),
|
||||
It.IsAny<Dictionary<string,string>>(),
|
||||
It.IsAny<string>())).ReturnsAsync(personsJsonResponse);
|
||||
var result = await _personDao.FindByPersonsName(coreRequestParameters, personRequest);
|
||||
|
||||
Assert.IsNull(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetPersonNumbersByNameLike_AllCases_ExecutesPersonNumberByNameLikeQueryWithNameAndLimitParameters()
|
||||
{
|
||||
var query = QueryUtilities.GetQuery("Person/PersonNumberByNameLikeQuery");
|
||||
var firstName = Guid.NewGuid().ToString().ToUpperInvariant();
|
||||
var middleName = Guid.NewGuid().ToString().ToUpperInvariant();
|
||||
var lastName = Guid.NewGuid().ToString().ToUpperInvariant();
|
||||
var limit = DateTime.Now.Millisecond;
|
||||
var resultSeries = new Random(DateTime.Now.Millisecond);
|
||||
var results = new long[]{ resultSeries.Next(), resultSeries.Next(), resultSeries.Next() };
|
||||
_mockCoreDbExecution
|
||||
.Setup(c => c.ExecuteQuery<long, dynamic>(query, It.Is<object>(q => q.GetPropertyValue<string>("firstName") == firstName.ToLowerInvariant() && q.GetPropertyValue<string>("middleName") == middleName.ToLowerInvariant() && q.GetPropertyValue<string>("lastName") == lastName.ToLowerInvariant() && q.GetPropertyValue<int>("limit") == limit)))
|
||||
.Returns(Task.FromResult<IEnumerable<long>>(results));
|
||||
|
||||
var organizationNumbers = await _personDao.GetPersonNumbersByNameLike(firstName, middleName, lastName, limit);
|
||||
|
||||
Assert.AreSame(results, organizationNumbers);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CountPersonsByNameLike_AllCases_ExecutesPersonByNameLikeCountWithNameParameters()
|
||||
{
|
||||
var query = QueryUtilities.GetQuery("Person/PersonByNameLikeCount");
|
||||
var firstName = Guid.NewGuid().ToString().ToUpperInvariant();
|
||||
var middleName = Guid.NewGuid().ToString().ToUpperInvariant();
|
||||
var lastName = Guid.NewGuid().ToString().ToUpperInvariant();
|
||||
var count = DateTime.Now.Millisecond;
|
||||
var results = new long[]{ count };
|
||||
_mockCoreDbExecution
|
||||
.Setup(c => c.ExecuteQuery<long, dynamic>(query, It.Is<object>(q => q.GetPropertyValue<string>("firstName") == firstName.ToLowerInvariant() && q.GetPropertyValue<string>("middleName") == middleName.ToLowerInvariant() && q.GetPropertyValue<string>("lastName") == lastName.ToLowerInvariant())))
|
||||
.Returns(Task.FromResult<IEnumerable<long>>(results));
|
||||
|
||||
var organizationCount = await _personDao.CountPersonsByNameLike(firstName, middleName, lastName);
|
||||
|
||||
Assert.AreEqual(count, organizationCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using System.Linq;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using LCU.Library.Internal.CoreApiWrapperLib.DataAccess;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels;
|
||||
using LCU.Library.Internal.CoreApiWrapperLib.Configuration;
|
||||
using LCU.Library.Internal.CoreApiWrapperLib.CoreApiUtilities;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Tax;
|
||||
|
||||
namespace LCU.Api.Internal.CoreApiWrapperTest.DataAccess
|
||||
{
|
||||
public class TaxDaoTest
|
||||
{
|
||||
private TaxDao _taxDao;
|
||||
private Mock<ICoreRequest> _mockCoreRequest;
|
||||
private CoreConfiguration _coreConfiguration;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
_mockCoreRequest = new Mock<ICoreRequest>();
|
||||
|
||||
_coreConfiguration = new CoreConfiguration
|
||||
{
|
||||
CoreApiConfiguration = new CoreApiConfiguration
|
||||
{
|
||||
CoreEndPointConfiguration = new CoreEndPointConfiguration
|
||||
{
|
||||
GetOrganizationsDataByTaxId = "test/Organization/Query/TaxId",
|
||||
GetPersonsDataByTaxId = "test/Person/Query/TaxId"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
_taxDao = new TaxDao(_mockCoreRequest.Object, _coreConfiguration);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetPersonTaxIdData_Returns_Success()
|
||||
{
|
||||
var header = new CoreMessageHeader
|
||||
{
|
||||
UpdateKey = null,
|
||||
MessageId = null
|
||||
};
|
||||
|
||||
var body = new List<PersonTaxIdDataResponse>{
|
||||
new()
|
||||
{
|
||||
FirstName = "Greg",
|
||||
MiddleInitial = "H",
|
||||
LastName = "Stevens",
|
||||
Suffix = "Jr.",
|
||||
NameFull = "Greg H. Stevens Jr.",
|
||||
PersonNumber = 123
|
||||
}
|
||||
};
|
||||
var personTaxIdDataResponse = new CoreApiMessage<IEnumerable<PersonTaxIdDataResponse>>(header, body);
|
||||
|
||||
_mockCoreRequest.Setup(x => x.PostRequestObject<CoreApiMessage<IEnumerable<PersonTaxIdDataResponse>>>(It.Is<string>(url => url.Equals("test/Person/Query/TaxId")), It.IsAny<Dictionary<string, string>>() ,It.Is<string>(x => x.Contains("123")))).ReturnsAsync(personTaxIdDataResponse).Verifiable();
|
||||
|
||||
var results = await _taxDao.GetPersonTaxIdData(new CoreRequestParameters(), "123");
|
||||
Assert.IsNotNull(results);
|
||||
Assert.AreEqual(1, results.Count());
|
||||
_mockCoreRequest.Verify();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetOrganizationTaxIdData_Returns_Success()
|
||||
{
|
||||
var header = new CoreMessageHeader
|
||||
{
|
||||
UpdateKey = null,
|
||||
MessageId = null
|
||||
};
|
||||
|
||||
var body = new List<OrganizationTaxIdDataResponse>{
|
||||
new()
|
||||
{
|
||||
Name = "Organization",
|
||||
OrganizationNumber = 123
|
||||
}
|
||||
};
|
||||
var personTaxIdDataResponse = new CoreApiMessage<IEnumerable<OrganizationTaxIdDataResponse>>(header, body);
|
||||
|
||||
_mockCoreRequest.Setup(x => x.PostRequestObject<CoreApiMessage<IEnumerable<OrganizationTaxIdDataResponse>>>(It.Is<string>(url => url.Equals("test/Organization/Query/TaxId")), It.IsAny<Dictionary<string, string>>() ,It.Is<string>(url => url.Contains("123")))).ReturnsAsync(personTaxIdDataResponse).Verifiable();
|
||||
|
||||
var results = await _taxDao.GetOrganizationTaxIdData(new CoreRequestParameters(), "123");
|
||||
Assert.IsNotNull(results);
|
||||
Assert.AreEqual(1, results.Count());
|
||||
_mockCoreRequest.Verify();
|
||||
}
|
||||
}
|
||||
}
|
||||
+233
@@ -0,0 +1,233 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using LCU.Library.Internal.ApiSecurity.Models;
|
||||
using LCU.Library.Internal.CoreApiWrapperLib.Configuration;
|
||||
using LCU.Library.Internal.CoreApiWrapperLib.CoreApiUtilities;
|
||||
using LCU.Library.Internal.CoreApiWrapperLib.CoreDbUtilities;
|
||||
using LCU.Library.Internal.CoreApiWrapperLib.DataAccess;
|
||||
using LCU.Library.Internal.CoreApiWrapperLib.Utilities;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreRequests;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Transaction;
|
||||
using LCU.Library.Internal.LcuHttpClient.HttpRequest;
|
||||
|
||||
namespace LCU.Api.Internal.CoreApiWrapperTest.DataAccess
|
||||
{
|
||||
public class TransactionDaoTest
|
||||
{
|
||||
private TransactionDao _transactionDao;
|
||||
private Mock<ICoreRequest> _mockCoreRequest;
|
||||
private CoreConfiguration _coreConfiguration;
|
||||
private ApiSecurityConfiguration _apiSecurityConfiguration;
|
||||
private Mock<ICoreDbExecution> _mockCoreDbExecution;
|
||||
private Mock<IPostRequest> _mockPostRequest;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
_mockCoreRequest = new Mock<ICoreRequest>();
|
||||
_mockCoreDbExecution = new Mock<ICoreDbExecution>();
|
||||
_mockPostRequest = new Mock<IPostRequest>();
|
||||
|
||||
_coreConfiguration = new CoreConfiguration()
|
||||
{
|
||||
CoreSoapApiConfiguration = new CoreSoapApiConfiguration()
|
||||
{
|
||||
CoreSoapEndpointConfiguration = new CoreSoapEndpointConfiguration()
|
||||
{
|
||||
PostMonetaryTransactions = "TEST/MonetaryTransaction/PostMonetaryTransactions"
|
||||
}
|
||||
},
|
||||
CoreApiConfiguration = new CoreApiConfiguration()
|
||||
{
|
||||
CoreEndPointConfiguration = new CoreEndPointConfiguration()
|
||||
{
|
||||
AccountsTransactionHistoryQueryAccountNumber = "test/AccountsTransactionHistoryQueryAccountNumber"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
_apiSecurityConfiguration = new ApiSecurityConfiguration()
|
||||
{
|
||||
InternalApiKeySet = new Dictionary<string, string>()
|
||||
{
|
||||
["CoreSoapApiWrapper"] = "TEST"
|
||||
}
|
||||
};
|
||||
|
||||
_transactionDao = new TransactionDao(_mockCoreRequest.Object,
|
||||
_coreConfiguration,
|
||||
_apiSecurityConfiguration,
|
||||
_mockCoreDbExecution.Object,
|
||||
_mockPostRequest.Object);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AddMonetaryTransactions_Returns_Two()
|
||||
{
|
||||
var response = new List<MonetaryTransactionResponse>()
|
||||
{
|
||||
new()
|
||||
{
|
||||
WasSuccessful = true
|
||||
},
|
||||
new()
|
||||
{
|
||||
WasSuccessful = true
|
||||
}
|
||||
};
|
||||
|
||||
_mockPostRequest.Setup(x => x.Async<List<GroupedMonetaryTransactionRequest>, List<MonetaryTransactionResponse>>(It.IsAny<Uri>(),
|
||||
It.IsAny<List<GroupedMonetaryTransactionRequest>>(),
|
||||
It.IsAny<Dictionary<string, string>>(),
|
||||
It.IsAny<int>(),
|
||||
It.IsAny<int>()))
|
||||
.ReturnsAsync(response).Verifiable();
|
||||
|
||||
var groupRequest = new GroupedMonetaryTransactionRequest()
|
||||
{
|
||||
ParentRequestNumber = "1",
|
||||
MonetaryTransactionRequests =
|
||||
[
|
||||
new MonetaryTransactionRequest()
|
||||
{
|
||||
AccountNumber = 19617805142,
|
||||
ApprovalPersonNumber = 5225,
|
||||
RequestNumber = "1",
|
||||
OverrideCashBoxNumber = 800,
|
||||
TransactionTypeCode = "DEXP",
|
||||
Description = "",
|
||||
BalanceTypes =
|
||||
[
|
||||
new BalanceType1()
|
||||
{
|
||||
BalanceCategoryCode = "UPFR",
|
||||
BalanceTypeCode = "DLR",
|
||||
BalanceTypeAmount = 1.27
|
||||
}
|
||||
],
|
||||
FundBalanceTypes =
|
||||
[
|
||||
new FundBalanceType()
|
||||
{
|
||||
FundBalanceAmount = 1.27,
|
||||
FundTypeCode = "EL",
|
||||
FundTypeDetailCode = "IMED"
|
||||
}
|
||||
],
|
||||
Funds =
|
||||
[
|
||||
new Fund()
|
||||
{
|
||||
ClearingCategoryCode = "IMED",
|
||||
FundAmount = 1.27,
|
||||
FundTypeCode = "EL",
|
||||
FundTypeDetailCode = "INTR",
|
||||
NumberOfItems = 1
|
||||
}
|
||||
]
|
||||
},
|
||||
new MonetaryTransactionRequest()
|
||||
{
|
||||
AccountNumber = 19617805142,
|
||||
TransactionAmount = -1.27,
|
||||
ApprovalPersonNumber = 5225,
|
||||
RequestNumber = "2",
|
||||
ParentRequestNumber = "1",
|
||||
OverrideCashBoxNumber = 800,
|
||||
TransactionTypeCode = "DRIR",
|
||||
Description = "",
|
||||
BalanceTypes =
|
||||
[
|
||||
new()
|
||||
{
|
||||
BalanceCategoryCode = "UPFR",
|
||||
BalanceTypeCode = "DLR",
|
||||
BalanceTypeAmount = -1.27
|
||||
}
|
||||
],
|
||||
Funds =
|
||||
[
|
||||
new Fund()
|
||||
{
|
||||
ClearingCategoryCode = "IMED",
|
||||
FundAmount = -1.27,
|
||||
FundTypeCode = "EL",
|
||||
FundTypeDetailCode = "INTR",
|
||||
NumberOfItems = 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
var listGroupRequest = new List<GroupedMonetaryTransactionRequest> { groupRequest };
|
||||
|
||||
var results = await _transactionDao.AddMonetaryTransactions(listGroupRequest);
|
||||
Assert.IsNotNull(results);
|
||||
Assert.AreEqual(2, results.Count);
|
||||
_mockPostRequest.Verify();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AddMonetaryTransactions_Exception()
|
||||
{
|
||||
var listGroupRequest = new List<GroupedMonetaryTransactionRequest> { new() };
|
||||
var endpoint = HttpUtilities.BuildHttpsUri(_coreConfiguration.CoreSoapApiConfiguration.CoreSoapApiWrapperHost,
|
||||
_coreConfiguration.CoreSoapApiConfiguration.CoreSoapEndpointConfiguration.PostMonetaryTransactions);
|
||||
|
||||
_mockPostRequest.Setup(x => x.Async<List<GroupedMonetaryTransactionRequest>, List<MonetaryTransactionResponse>>(endpoint,
|
||||
It.IsAny<List<GroupedMonetaryTransactionRequest>>(),
|
||||
It.IsAny<Dictionary<string, string>>(),
|
||||
It.IsAny<int>(),
|
||||
It.IsAny<int>()))
|
||||
.Throws(new Exception("Error thrown in unit test.")).Verifiable();
|
||||
|
||||
Assert.ThrowsAsync<Exception>(async () => await _transactionDao.AddMonetaryTransactions(listGroupRequest));
|
||||
_mockPostRequest.Verify();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task FindTransactionHistoryById_Return_Two()
|
||||
{
|
||||
var messageBody = new List<TransactionHistory>()
|
||||
{
|
||||
new TransactionHistory()
|
||||
{
|
||||
AccountNumber = 1234555,
|
||||
ActivityDateTime = Convert.ToDateTime("1/1/2021")
|
||||
},
|
||||
new TransactionHistory()
|
||||
{
|
||||
AccountNumber = 1234555,
|
||||
ActivityDateTime = Convert.ToDateTime("1/2/2021")
|
||||
}
|
||||
};
|
||||
|
||||
var messageHeader = new CoreMessageHeader() { };
|
||||
var returnValue = new CoreApiMessage<IEnumerable<TransactionHistory>>(messageHeader, messageBody);
|
||||
|
||||
_mockCoreRequest
|
||||
.Setup(x => x.PostRequestObject<CoreApiMessage<IEnumerable<TransactionHistory>>>(It.IsAny<string>(),
|
||||
It.IsAny<Dictionary<string, string>>(),
|
||||
It.IsAny<string>()))
|
||||
.ReturnsAsync(returnValue).Verifiable();
|
||||
|
||||
|
||||
var coreRequestParameters = new CoreRequestParameters() { };
|
||||
var transactionHistoryRequest = new TransactionHistoryRequest() { };
|
||||
|
||||
var results = await _transactionDao.FindTransactionHistoryById(coreRequestParameters, transactionHistoryRequest, "dfasdfasdp-adfsdafafd-asfsadf");
|
||||
|
||||
var resultsList = results.ToList();
|
||||
Assert.NotNull(results);
|
||||
Assert.AreEqual(2, resultsList.Count);
|
||||
Assert.True(resultsList.Any(x => x.AccountNumber == 1234555));
|
||||
|
||||
_mockCoreRequest.Verify();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user