163 lines
6.2 KiB
C#
163 lines
6.2 KiB
C#
using LCU.Api.Internal.CoreApiWrapper.Controllers;
|
|
using LCU.Api.Internal.CoreApiWrapper.Services;
|
|
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.IndirectLoan;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Moq;
|
|
using NUnit.Framework;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace LCU.Api.Internal.CoreApiWrapperTest.Controllers
|
|
{
|
|
public class IndirectLoanControllerTest
|
|
{
|
|
private IndirectLoanController _indirectLoanController;
|
|
private Mock<IIndirectLoanService> _mockIndirectLoanService;
|
|
|
|
[SetUp]
|
|
public void SetUp()
|
|
{
|
|
_mockIndirectLoanService = new Mock<IIndirectLoanService>();
|
|
_indirectLoanController = new IndirectLoanController(_mockIndirectLoanService.Object);
|
|
}
|
|
|
|
[Test]
|
|
public async Task GetIndirectLoanByAccountNumber_OK()
|
|
{
|
|
_mockIndirectLoanService.Setup(x => x.GetIndirectLoanByAccountNumber(It.IsAny<long>())).ReturnsAsync(new IndirectLoanDetail());
|
|
|
|
var result = await _indirectLoanController.GetIndirectLoanByAccountNumber(1234);
|
|
|
|
Assert.NotNull(result);
|
|
var okResult = result as OkObjectResult;
|
|
Assert.NotNull(okResult);
|
|
Assert.AreEqual(200, okResult.StatusCode);
|
|
}
|
|
|
|
[Test]
|
|
public async Task GetIndirectLoanByAccountNumber_Exception()
|
|
{
|
|
_mockIndirectLoanService.Setup(x => x.GetIndirectLoanByAccountNumber(It.IsAny<long>()))
|
|
.Throws(new Exception("Oops"));
|
|
|
|
var result = await _indirectLoanController.GetIndirectLoanByAccountNumber(1234);
|
|
|
|
Assert.NotNull(result);
|
|
var badResult = result as StatusCodeResult;
|
|
Assert.NotNull(badResult);
|
|
Assert.AreEqual(500, badResult.StatusCode);
|
|
}
|
|
|
|
[Test]
|
|
public async Task GetIndirectLoanByPostedDate_OK()
|
|
{
|
|
_mockIndirectLoanService.Setup(x => x.GetIndirectLoansByPostedDate(It.IsAny<string>())).ReturnsAsync(new List<IndirectLoanDetail>());
|
|
|
|
var result = await _indirectLoanController.GetIndirectLoansByPostedDate("5/1/2021");
|
|
|
|
Assert.NotNull(result);
|
|
var okResult = result as OkObjectResult;
|
|
Assert.NotNull(okResult);
|
|
Assert.AreEqual(200, okResult.StatusCode);
|
|
}
|
|
|
|
[Test]
|
|
public async Task GetIndirectLoanByPostedDate_Exception()
|
|
{
|
|
_mockIndirectLoanService.Setup(x => x.GetIndirectLoansByPostedDate(It.IsAny<string>()))
|
|
.Throws(new Exception("Oops"));
|
|
|
|
var result = await _indirectLoanController.GetIndirectLoansByPostedDate("5/1/2021");
|
|
|
|
Assert.NotNull(result);
|
|
var badResult = result as StatusCodeResult;
|
|
Assert.NotNull(badResult);
|
|
Assert.AreEqual(500, badResult.StatusCode);
|
|
}
|
|
|
|
[Test]
|
|
public async Task GetClosedIndirectLoanByPostedDate_OK()
|
|
{
|
|
_mockIndirectLoanService.Setup(x => x.GetClosedIndirectLoansByPostedDate(It.IsAny<string>())).ReturnsAsync(new List<ClosedIndirectLoan>());
|
|
|
|
var result = await _indirectLoanController.GetClosedIndirectLoansByPostedDate("5/1/2021");
|
|
|
|
Assert.NotNull(result);
|
|
var okResult = result as OkObjectResult;
|
|
Assert.NotNull(okResult);
|
|
Assert.AreEqual(200, okResult.StatusCode);
|
|
}
|
|
|
|
[Test]
|
|
public async Task GetClosedIndirectLoanByPostedDate_Exception()
|
|
{
|
|
_mockIndirectLoanService.Setup(x => x.GetClosedIndirectLoansByPostedDate(It.IsAny<string>()))
|
|
.Throws(new Exception("Oops"));
|
|
|
|
var result = await _indirectLoanController.GetClosedIndirectLoansByPostedDate("5/1/2021");
|
|
|
|
Assert.NotNull(result);
|
|
var badResult = result as StatusCodeResult;
|
|
Assert.NotNull(badResult);
|
|
Assert.AreEqual(500, badResult.StatusCode);
|
|
}
|
|
|
|
[Test]
|
|
public async Task GetClosedIndirectLoanWithDetailByPostedDate_OK()
|
|
{
|
|
_mockIndirectLoanService.Setup(x => x.GetClosedIndirectLoansWithDetailByPostedDate(It.IsAny<string>())).ReturnsAsync(new List<IndirectLoanDetail>());
|
|
|
|
var result = await _indirectLoanController.GetClosedIndirectLoansWithDetailByPostedDate("5/1/2021");
|
|
|
|
Assert.NotNull(result);
|
|
var okResult = result as OkObjectResult;
|
|
Assert.NotNull(okResult);
|
|
Assert.AreEqual(200, okResult.StatusCode);
|
|
}
|
|
|
|
[Test]
|
|
public async Task GetClosedIndirectLoanWithDetailByPostedDate_Exception()
|
|
{
|
|
_mockIndirectLoanService.Setup(x => x.GetClosedIndirectLoansWithDetailByPostedDate(It.IsAny<string>()))
|
|
.Throws(new Exception("Oops"));
|
|
|
|
var result = await _indirectLoanController.GetClosedIndirectLoansWithDetailByPostedDate("5/1/2021");
|
|
|
|
Assert.NotNull(result);
|
|
var badResult = result as StatusCodeResult;
|
|
Assert.NotNull(badResult);
|
|
Assert.AreEqual(500, badResult.StatusCode);
|
|
}
|
|
|
|
[Test]
|
|
public async Task PutDealerOriginalBalance_Ok()
|
|
|
|
{
|
|
var accountNumber = "111111111111";
|
|
_mockIndirectLoanService.Setup(x => x.UpdateDealerOriginalBalance(It.IsAny<string>())).ReturnsAsync(
|
|
new List<UpdateDealerOriginalBalanceResponse>() { });
|
|
|
|
var result = await _indirectLoanController.PutDealerOriginalBalance(accountNumber);
|
|
|
|
var okResult = result as OkObjectResult;
|
|
Assert.NotNull(okResult);
|
|
Assert.AreEqual(200, okResult.StatusCode);
|
|
}
|
|
|
|
[Test]
|
|
public async Task PutDealerOriginalBalance_Exception()
|
|
{
|
|
var accountNumber = "111111111111";
|
|
_mockIndirectLoanService.Setup(x => x.UpdateDealerOriginalBalance(It.IsAny<string>()))
|
|
.Throws(new Exception("Oops"));
|
|
|
|
var results = await _indirectLoanController.PutDealerOriginalBalance(accountNumber);
|
|
|
|
Assert.NotNull(results);
|
|
var badResult = results as StatusCodeResult;
|
|
Assert.NotNull(badResult);
|
|
Assert.AreEqual(500, badResult.StatusCode);
|
|
}
|
|
}
|
|
} |