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 _mockRepository; private Mock _mockUnitOfWork; public RepoCompanySelectionServiceTest() { _mockRepository = new Mock(); _mockUnitOfWork = new Mock(); _repoCompanySelectionService = new RepoCompanySelectionService( _mockRepository.Object, _mockUnitOfWork.Object); } [Fact] public async void UpdateAsync_Success() { // Arrange var list = new List() { 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())).ReturnsAsync(new RepoCompanySelection() { RepoCompanyId = 3 }); _mockRepository.Setup(repository => repository.FindByCollateralIdAsync(It.IsAny())).ReturnsAsync(new List() { new RepoCompanySelection() { Id = 1 } }); // Act await _repoCompanySelectionService.SaveChangesAsync(list); Assert.Collection(list, item => { Assert.NotNull(item.DateTimeCreated); }, item => { Assert.NotNull(item.DateTimeCreated); }); } } }