83 lines
2.8 KiB
C#
83 lines
2.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using LCU.API.Collections.CollectionsApiLib.Models;
|
|
using LCU.API.Collections.RepoApi.Services;
|
|
using LCU.Shared.Collections.RepoApiLib.Models;
|
|
using LCU.Shared.Collections.RepoApiLib.Repositories;
|
|
using Moq;
|
|
using Xunit;
|
|
|
|
namespace LCU.API.Collections.RepoApiTests.Services
|
|
{
|
|
public class RepoCompanySelectionServiceTest
|
|
{
|
|
private RepoCompanySelectionService _repoCompanySelectionService;
|
|
private Mock<IRepoCompanySelectionRepository> _mockRepository;
|
|
private Mock<IUnitOfWork> _mockUnitOfWork;
|
|
|
|
public RepoCompanySelectionServiceTest()
|
|
{
|
|
_mockRepository = new Mock<IRepoCompanySelectionRepository>();
|
|
_mockUnitOfWork = new Mock<IUnitOfWork>();
|
|
_repoCompanySelectionService = new RepoCompanySelectionService(
|
|
_mockRepository.Object,
|
|
_mockUnitOfWork.Object);
|
|
}
|
|
|
|
[Fact]
|
|
public async void UpdateAsync_Success()
|
|
{
|
|
// Arrange
|
|
var list = new List<RepoCompanySelection>()
|
|
{
|
|
new RepoCompanySelection()
|
|
{
|
|
Id = 1,
|
|
CollateralId = 2,
|
|
RepoCompanyId = 3,
|
|
RepoType = RepoType.Involuntary,
|
|
DateTimeCreated = DateTime.Parse("08/14/1945"),
|
|
RepoCompanyAssignmentDate = DateTime.Parse("04/24/1916"),
|
|
DateRepoed = DateTime.Parse("04/29/1916")
|
|
},
|
|
new RepoCompanySelection()
|
|
{
|
|
CollateralId = 2,
|
|
RepoCompanyId = 13,
|
|
RepoType = RepoType.Involuntary,
|
|
DateTimeCreated = DateTime.Parse("08/14/1945"),
|
|
RepoCompanyAssignmentDate = DateTime.Parse("04/24/1916"),
|
|
DateRepoed = DateTime.Parse("04/29/1916")
|
|
}
|
|
};
|
|
|
|
_mockRepository.Setup(repository => repository.FindByIdAsync(It.IsAny<int>())).ReturnsAsync(new RepoCompanySelection()
|
|
{
|
|
RepoCompanyId = 3
|
|
});
|
|
|
|
_mockRepository.Setup(repository => repository.FindByCollateralIdAsync(It.IsAny<int>())).ReturnsAsync(new List<RepoCompanySelection>()
|
|
{
|
|
new RepoCompanySelection()
|
|
{
|
|
Id = 1
|
|
}
|
|
});
|
|
|
|
// Act
|
|
await _repoCompanySelectionService.SaveChangesAsync(list);
|
|
|
|
Assert.Collection(list,
|
|
item =>
|
|
{
|
|
Assert.NotNull(item.DateTimeCreated);
|
|
},
|
|
item =>
|
|
{
|
|
Assert.NotNull(item.DateTimeCreated);
|
|
});
|
|
}
|
|
|
|
}
|
|
}
|