This commit is contained in:
Zeeshaun
2026-04-20 14:47:24 -05:00
parent 89057eceea
commit 8b3ea92501
485 changed files with 71042 additions and 0 deletions
@@ -0,0 +1,215 @@
using System;
using System.Collections.Generic;
using System.Linq;
using LCU.Shared.Collections.RepoApiLib.Exceptions;
using LCU.Shared.Collections.RepoApiLib.Models;
using LCU.Shared.Collections.RepoApiLib.Persistence;
using LCU.Shared.Collections.RepoApiLib.Repositories;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Xunit;
namespace LCU.API.Collections.RepoApiTests.Repository
{
public class EventAlertRepositoryTest : DbContextFromJson
{
private Shared.Collections.RepoApiLib.Repositories.EventAlertRepository _repository;
private readonly AppDbContext _dbContext;
public EventAlertRepositoryTest()
{
_dbContext = GetSqliteContextWithData("event_alert_repository.json");
_repository = new EventAlertRepository(_dbContext);
}
[Fact]
public async void ListAllAsync_Test()
{
var resultsBasic = await _repository.ListAllAsync();
Assert.NotNull(resultsBasic);
Assert.NotEmpty(resultsBasic);
Assert.Equal("Unit Test", resultsBasic.First().CreatedBy);
}
[Fact]
public async void ListUnreadEventsAsync_Test()
{
var resultsBasic = await _repository.ListUnreadAsync();
Assert.NotNull(resultsBasic);
Assert.NotEmpty(resultsBasic);
Assert.Equal(1, resultsBasic.Count());
}
[Fact]
public async void ListO4R_No_Company_Test()
{
var resultsBasic = await _repository.ListO4rNoCompanyAsync();
Assert.NotNull(resultsBasic);
Assert.NotEmpty(resultsBasic);
Assert.Single(resultsBasic);
}
[Fact]
public async void ListRepo_No_Company_Test()
{
var resultsBasic = await _repository.ListRepoNoCompanyAsync();
Assert.NotNull(resultsBasic);
Assert.NotEmpty(resultsBasic);
Assert.Equal(1, resultsBasic.Count());
}
[Fact]
public async void ListRepo_No_Auction_Test()
{
var resultsBasic = await _repository.ListRepoNoAuctionAsync();
Assert.NotNull(resultsBasic);
// There is 1, but it is closed.
Assert.Empty(resultsBasic);
}
[Fact]
public async void ListReadyForRetitleAsync_Test()
{
var resultsBasic = await _repository.ListAllAsync();
Assert.NotNull(resultsBasic);
Assert.NotEmpty(resultsBasic);
IEnumerable<EventAlert> results = await _repository.ListReadyForRetitleAsync();
Assert.NotNull(results);
Assert.NotEmpty(results);
Assert.Equal(1, results.Count());
}
[Fact]
public async void AddAsync_DoesNotThrowWhenAlertShouldRepeat_Test()
{
var alert = new EventAlert
{
RepoId = 11688,
AccountNo = "6829620143",
Message = "test",
CreatedBy = "Unit Test",
DateAdded = DateTime.Parse("2019-06-29T00:00:00")
};
await _repository.AddAsync(alert);
await _dbContext.SaveChangesAsync();
}
[Fact]
public async void AddAsync_Invalid_Test()
{
var alert = new EventAlert
{
RepoId = 11688,
AccountNo = "6829620143",
Message = "test",
CreatedBy = "012345678901234567890123456789",
DateAdded = DateTime.Parse("2019-06-29T00:00:00")
};
await _repository.AddAsync(alert);
await _dbContext.SaveChangesAsync();
}
[Fact]
public async void AddAsync_ThrowsWhenAlertShouldNotRepeat_Test()
{
var alert = new EventAlert()
{
RepoId = 11688,
AccountNo = "6829620143",
Message = "RTC Letter Not Found",
CreatedBy = "Unit Test",
DateAdded = DateTime.Parse("2019-06-29T00:00:00")
};
await Assert.ThrowsAsync<DuplicateResourceException>(() => _repository.AddAsync(alert));
}
[Fact]
public async void AddAsync_Empty_Test()
{
await _repository.AddRangeAsync(new List<EventAlert>());
await _dbContext.SaveChangesAsync();
}
[Theory]
[InlineData(14883, "9987149147", "test", true)] //This Data Already Exists in event_alert_repository.json
[InlineData(00001, "0000000001", "test", false)]
[InlineData(14883, "9987149147", "not test", false)]
public void IsDuplicateAlert_Ok(int RepoID, string AccountNo, string Message, bool expected)
{
var alert = new EventAlert
{
RepoId = RepoID,
AccountNo = AccountNo,
Message = Message,
CreatedBy = "Unit Test",
DateAdded = DateTime.Parse("2019-06-27T00:00:00"),
};
Assert.Equal(_repository.IsDuplicateAlert(alert), expected);
}
[Fact]
public void IsDuplicateAlert_NonRepeatingAlerts_OK()
{
var alert = new EventAlert
{
RepoId = 11688,
AccountNo = "6829620143",
Message = "Payment Received",
CreatedBy = "Unit Test",
DateAdded = DateTime.Parse("2019-06-27T00:00:00"),
MarkedReadBy = "tester"
};
Assert.False(_repository.IsDuplicateAlert(alert));
}
[Fact]
public async void AddRangeAsync_Ignores_Duplicates_OK()
{
List<EventAlert> eventAlerts = new List<EventAlert> {
new EventAlert
{
RepoId = 11688,
AccountNo = "6829620143",
Message = "Payment Received",
CreatedBy = "Unit Test",
DateAdded = DateTime.Parse("2019-06-27T00:00:00"),
MarkedReadBy = "tester"
},
new EventAlert()
{
RepoId = 1,
AccountNo = "6829627143",
CreatedBy = "Unit Test",
Message = "Payment Received",
DateAdded = DateTime.Parse("2019-06-27T00:00:00")
},
new EventAlert()
{
RepoId = 2,
AccountNo = "6829628143",
CreatedBy = "Unit Test",
Message = "Payment Received",
DateAdded = DateTime.Parse("2019-06-27T00:00:00")
},
};
var results = await _repository.AddRangeAsync(eventAlerts);
await _dbContext.SaveChangesAsync();
Assert.Equal(3,results.Count());
Assert.True(results.ToList().Exists(x => x.RepoId == 11688));
}
[Fact]
public async void ListUnreadByAccountNoAsync_Ok()
{
var results = await _repository.ListUnreadByAccountNoAsync("9987149147");
Assert.Single(results);
}
}
}
@@ -0,0 +1,112 @@
using System;
using System.Collections.Generic;
using Xunit;
using System.Linq;
using LCU.Shared.Collections.RepoApiLib.Models;
using LCU.Shared.Collections.RepoApiLib.Repositories;
using LCU.Shared.Collections.RepoApiLib.Persistence;
using Microsoft.EntityFrameworkCore;
namespace LCU.API.Collections.RepoApiTests.Repository
{
public class ExternalUserRepository : DbContextFromJson
{
private readonly AppDbContext _dbContext;
public ExternalUserRepository()
{
_dbContext = SqliteDbContext;
}
[Fact]
public async void External_Users_Sync_Ok()
{
var repository = new Shared.Collections.RepoApiLib.Repositories.ExternalUserRepository(_dbContext);
// act
var list = new List<ExternalUser>()
{
new ExternalUser()
{
ReferenceId = 100,
Code = "gfrick",
Name = "George Frick"
},
new ExternalUser()
{
ReferenceId = 101,
Code = "astiyer",
Name = "Alex Stiyer"
},
new ExternalUser()
{
ReferenceId = 102,
Code = "mfleming",
Name = "Mitchel Flemming"
}
};
await repository.SynchronizeSet(list);
await _dbContext.SaveChangesAsync();
// fake restart the context / transaction
foreach (var user in list)
{
_dbContext.Entry(user).State = EntityState.Detached;
}
//assert finds multiple
var results = await repository.ListAsync();
Assert.NotNull(results);
Assert.NotEmpty(results);
Assert.Equal(3 , results.Count());
//assert finds one
var result = await repository.FindByReferenceIdAsync(101);
Assert.NotNull(result);
Assert.Equal("astiyer", result.Code);
var list2 = new List<ExternalUser>()
{
new ExternalUser()
{
ReferenceId = 100,
Code = "gfrick",
Name = "George Frick"
},
new ExternalUser()
{
ReferenceId = 101,
Code = "astiyer",
Name = "Alex Stiyer"
},
new ExternalUser()
{
ReferenceId = 103,
Code = "kutley",
Name = "Kyle Utley"
},
new ExternalUser()
{
ReferenceId = 102,
Code = "mfleming",
Name = "Mitchel Flemming"
}
};
await repository.SynchronizeSet(list2);
await _dbContext.SaveChangesAsync();
//assert finds multiple
results = await repository.ListAsync();
Assert.NotNull(results);
Assert.NotEmpty(results);
Assert.Equal(4 , results.Count());
//assert finds one
result = await repository.FindByReferenceIdAsync(103);
Assert.NotNull(result);
Assert.Equal("kutley", result.Code);
}
}
}
@@ -0,0 +1,289 @@
using System;
using System.Collections.Generic;
using Xunit;
using System.Linq;
using LCU.Shared.Collections.RepoApiLib.Models;
using LCU.Shared.Collections.RepoApiLib.Models.Producer;
using LCU.Shared.Collections.RepoApiLib.Repositories;
using LCU.Shared.Collections.RepoApiLib.Persistence;
using Microsoft.EntityFrameworkCore;
namespace LCU.API.Collections.RepoApiTests.Repository
{
public class ProcessingReceiptRepository : DbContextFromJson
{
private readonly AppDbContext _dbContext;
public ProcessingReceiptRepository()
{
_dbContext = SqliteDbContext;
}
[Fact]
public async void ProcessingReceipt_Basic_Flow_OK()
{
var repository = new Shared.Collections.RepoApiLib.Repositories.ProcessingReceiptRepository(_dbContext);
// act
var result = await repository.FindReceiptsAsync("123456-789");
Assert.NotNull(result);
Assert.Empty(result);
var receipt = new ProcessingReceipt("123456-789")
{
Message = "x",
Outcome = RepoProcessingResult.Error,
Processed = DateTime.Now,
AccountId = "",
CaseId = "",
QueuedBy = "Testing"
};
await repository.AddOrUpdateAsync(receipt);
await _dbContext.SaveChangesAsync();
result = await repository.FindReceiptsAsync("123456-789");
// Assert
Assert.NotNull(result);
Assert.NotEmpty(result);
Assert.Equal(RepoProcessingResult.Error, result.First().Outcome);
}
[Fact]
public async void ProcessingReceipt_Multi_Flow_OK()
{
var repository = new Shared.Collections.RepoApiLib.Repositories.ProcessingReceiptRepository(_dbContext);
// act
var results = await repository.GetRetryListAsync();
Assert.NotNull(results);
Assert.Empty(results);
var list = new List<ProcessingReceipt>()
{
new ProcessingReceipt("123456-777")
{
Message = "x",
Outcome = RepoProcessingResult.Error,
Processed = DateTime.Now,
AccountId = "",
CaseId = "",
QueuedBy = "Testing"
},
new ProcessingReceipt("123456-888")
{
Message = "y",
Outcome = RepoProcessingResult.Created,
Processed = DateTime.Now,
AccountId = "",
CaseId = "",
QueuedBy = "Testing"
}
};
await repository.SaveAllAsync(list);
await _dbContext.SaveChangesAsync();
results = await repository.GetRetryListAsync();
// Assert
Assert.NotNull(results);
Assert.NotEmpty(results);
Assert.Equal(RepoProcessingResult.Error, results.First().Outcome);
}
[Fact]
public async void ProcessingReceipt_Update_OK()
{
var repository = new Shared.Collections.RepoApiLib.Repositories.ProcessingReceiptRepository(_dbContext);
// act
var list = new List<ProcessingReceipt>()
{
new ProcessingReceipt("123456-777")
{
Message = "x",
Outcome = RepoProcessingResult.Error,
Processed = DateTime.Now,
AccountId = "321",
CaseId = "",
QueuedBy = "Testing"
},
new ProcessingReceipt("123456-888")
{
Message = "y",
Outcome = RepoProcessingResult.Created,
Processed = DateTime.Now,
AccountId = "",
CaseId = "",
QueuedBy = "Testing"
}
};
await repository.SaveAllAsync(list);
await _dbContext.SaveChangesAsync();
// Fake the end of the transaction/etc with this...
_dbContext.Entry(list.First()).State = EntityState.Detached;
var changed = new ProcessingReceipt("123456-777")
{
Message = "x",
Outcome = RepoProcessingResult.MissingRequirement,
Processed = DateTime.Now,
AccountId = "321",
CaseId = "",
QueuedBy = "Testing"
};
await repository.AddOrUpdateAsync(changed);
await _dbContext.SaveChangesAsync();
var results = await repository.GetRetryListAsync();
// Assert
Assert.NotNull(results);
Assert.NotEmpty(results);
Assert.Equal(1, results.Count);
Assert.Equal(RepoProcessingResult.MissingRequirement, results.First().Outcome);
Assert.Equal("321", results.First().AccountId);
}
[Fact]
public async void ProcessingReceipt_MultiRecord_OK()
{
var repository = new Shared.Collections.RepoApiLib.Repositories.ProcessingReceiptRepository(_dbContext);
// act
var list = new List<ProcessingReceipt>()
{
new ProcessingReceipt("123456-777")
{
Message = "x1",
Outcome = RepoProcessingResult.Error,
Processed = DateTime.Now,
AccountId = "321",
CaseId = "",
QueuedBy = "Testing"
},
new ProcessingReceipt("123456-888")
{
Message = "y",
Outcome = RepoProcessingResult.Created,
Processed = DateTime.Now,
AccountId = "",
CaseId = "",
QueuedBy = "Testing"
}
};
await repository.SaveAllAsync(list);
await _dbContext.SaveChangesAsync();
// Fake the end of the transaction/etc with this...
_dbContext.Entry(list.First()).State = EntityState.Detached;
var changed = new ProcessingReceipt("123456-777")
{
Message = "x2",
Outcome = RepoProcessingResult.MissingRequirement,
Processed = DateTime.Now,
AccountId = "321",
CaseId = "123",
QueuedBy = "Testing"
};
await repository.AddOrUpdateAsync(changed);
await _dbContext.SaveChangesAsync();
var results = await repository.GetRetryListAsync();
// Assert
Assert.NotNull(results);
Assert.NotEmpty(results);
Assert.Equal(2, results.Count);
Assert.Equal(RepoProcessingResult.Error, results.First().Outcome);
Assert.Equal("321", results.First().AccountId);
Assert.Equal("x1", results.First().Message);
}
[Fact]
public async void GetReceiptByAccountNoAsync_OK()
{
var repository = new Shared.Collections.RepoApiLib.Repositories.ProcessingReceiptRepository(_dbContext);
// act
var list = new List<ProcessingReceipt>()
{
new ProcessingReceipt("123456-777")
{
Message = "x1",
Outcome = RepoProcessingResult.Error,
Processed = DateTime.Now,
AccountId = "321",
CaseId = "",
QueuedBy = "Testing"
},
new ProcessingReceipt("123456-888")
{
Message = "y",
Outcome = RepoProcessingResult.Created,
Processed = DateTime.Now,
AccountId = "",
CaseId = "",
QueuedBy = "Testing"
},
new ProcessingReceipt("123456-888")
{
Message = "y",
Outcome = RepoProcessingResult.Created,
Processed = DateTime.Now,
AccountId = "2",
CaseId = "22",
QueuedBy = "Testing"
}
};
await repository.SaveAllAsync(list);
await _dbContext.SaveChangesAsync();
// Fake the end of the transaction/etc with this...
_dbContext.Entry(list.First()).State = EntityState.Detached;
//assert finds multiple
var results = await repository.GetReceiptsByAccountNoAsync("123456-888");
Assert.NotNull(results);
Assert.NotEmpty(results);
Assert.Equal(2 , results.Count()); ;
Assert.All(results, (item) =>
{
Assert.Contains(item, results);
});
//assert finds one
results = await repository.GetReceiptsByAccountNoAsync("123456-777");
Assert.NotNull(results);
Assert.NotEmpty(results);
Assert.Single(results) ;
Assert.All(results, (item) =>
{
Assert.Contains(item, results);
});
//assert find empy
results = await repository.GetReceiptsByAccountNoAsync("000000-000");
Assert.NotNull(results);
Assert.Empty(results);
}
[Fact]
public async void GetReceiptByAccountNoAsync_EmptyContext()
{
var repository = new Shared.Collections.RepoApiLib.Repositories.ProcessingReceiptRepository(_dbContext);
// act
var list = new List<ProcessingReceipt>();
await repository.SaveAllAsync(list);
await _dbContext.SaveChangesAsync();
var results = await repository.GetReceiptsByAccountNoAsync("123456-888");
Assert.NotNull(results);
Assert.Empty(results);
}
}
}
@@ -0,0 +1,347 @@
using System;
using System.Collections.Generic;
using Xunit;
using System.Linq;
using LCU.API.Collections.CollectionsApiLib.Models;
using LCU.Shared.Collections.RepoApiLib.Models;
using LCU.Shared.Collections.RepoApiLib.Persistence;
using Microsoft.EntityFrameworkCore;
namespace LCU.API.Collections.RepoApiTests.Repository
{
public class RepoAccountRepository : DbContextFromJson
{
private readonly AppDbContext _dbContext;
public RepoAccountRepository()
{
_dbContext = GetSqliteContextWithData(@"Repository/repo_account_repository_data.json");
}
[Fact]
public async void ListAccounts_Filter_Closed_Ok()
{
var repoAccountRepos = new Shared.Collections.RepoApiLib.Repositories.RepoAccountRepository(_dbContext);
// act
var result = await repoAccountRepos.ListAsync(new List<int?> { }, 0, 10, null, null, null, true);
// Assert
Assert.NotNull(result);
Assert.Equal(2, result.Total);
Assert.True(result.Items.ToList().Exists(x => (x.RepoId == 2)));
Assert.True(result.Items.ToList().Exists(x => (x.RepoId == 1)));
Assert.False(result.Items.ToList().Exists(x => (x.RepoId == 3 || x.RepoId == 4)));
Assert.DoesNotContain(result.Items, x => x.DateClosed != null);
}
[Fact]
public async void FindAccount_Async_Missing_Ok()
{
var repoAccountRepos = new Shared.Collections.RepoApiLib.Repositories.RepoAccountRepository(_dbContext);
// act
var result = await repoAccountRepos.FindByAccountNoAsync("123456-999");
// Assert
Assert.NotNull(result);
Assert.Empty(result);
}
[Fact]
public async void ListAccounts_Filter_By_RepoCompanyID_Ok()
{
var repoAccountRepos = new Shared.Collections.RepoApiLib.Repositories.RepoAccountRepository(_dbContext);
// act
var result = await repoAccountRepos.ListAsync(new List<int?> { }, 0, 10, null, null, 4, null);
// Assert
Assert.NotNull(result);
Assert.Equal(1, result.Total);
Assert.Contains(result.Items, x => x.RepoId == 2);
Assert.DoesNotContain(result.Items, x => x.RepoId == 1 || x.RepoId == 3 || x.RepoId == 4);
}
[Fact]
public async void ListAccounts_Filter_By_AuctionHouseID_Ok()
{
var repoAccountRepos = new Shared.Collections.RepoApiLib.Repositories.RepoAccountRepository(_dbContext);
// act
var result = await repoAccountRepos.ListAsync(new List<int?> { }, 0, 10, null, "1259", null, null);
// Assert
Assert.NotNull(result);
Assert.Equal(1, result.Total);
Assert.Contains(result.Items, x => x.RepoId == 2);
Assert.DoesNotContain(result.Items, x => x.RepoId == 1 || x.RepoId == 3 || x.RepoId == 4);
}
[Fact]
public async void ListAccounts_Filter_By_Status_Ok()
{
var repoAccountRepos = new Shared.Collections.RepoApiLib.Repositories.RepoAccountRepository(_dbContext);
// act
var result = await repoAccountRepos.ListAsync(new List<int?> { }, 0, 10, "SOLD", null, null, null);
// Assert
Assert.NotNull(result);
Assert.Equal(1, result.Total);
Assert.Contains(result.Items, x => x.RepoId == 4);
Assert.DoesNotContain(result.Items, x => x.RepoId == 1 || x.RepoId == 2 || x.RepoId == 3);
}
[Fact]
public async void ListAccounts_Filter_By_Combination_RepoCompany_AuctionHouse_Ok()
{
var repoAccountRepos = new Shared.Collections.RepoApiLib.Repositories.RepoAccountRepository(_dbContext);
// act
var result = await repoAccountRepos.ListAsync(new List<int?> { }, 0, 10, null, "1259", 4, null);
// Assert
Assert.NotNull(result);
Assert.Equal(1, result.Total);
Assert.Contains(result.Items, x => x.RepoId == 2);
Assert.DoesNotContain(result.Items, x => x.RepoId == 1 || x.RepoId == 3 || x.RepoId == 4);
}
[Fact]
public async void ListAccounts_Filter_By_Combination_Open_AuctionHouse_Ok()
{
var repoAccountRepos = new Shared.Collections.RepoApiLib.Repositories.RepoAccountRepository(_dbContext);
// act
var result = await repoAccountRepos.ListAsync(new List<int?> { }, 0, 10, "PSKP", null, null, true);
// Assert
Assert.NotNull(result);
Assert.Equal(1, result.Total);
Assert.Contains(result.Items, x => x.RepoId == 1);
Assert.DoesNotContain(result.Items, x => x.RepoId == 2 || x.RepoId == 3 || x.RepoId == 4);
}
[Fact]
public async void ListAccounts_Filter_To_Null_OK()
{
var repoAccountRepos = new Shared.Collections.RepoApiLib.Repositories.RepoAccountRepository(_dbContext);
// act
var result = await repoAccountRepos.ListAsync(new List<int?> { }, 0, 10, "PSKP", "1259", 4, true);
// Assert
Assert.NotNull(result);
Assert.Empty(result.Items);
Assert.Equal(0, result.Total);
}
[Fact]
public async void ListAccounts_Filter_To_Doesnt_Exist_OK()
{
var repoAccountRepos = new Shared.Collections.RepoApiLib.Repositories.RepoAccountRepository(_dbContext);
// act
var result = await repoAccountRepos.ListAsync(new List<int?> { }, 0, 10, "THISDOESNTEXIST", null, null, null);
// Assert
Assert.NotNull(result);
Assert.Empty(result.Items);
Assert.Equal(0, result.Total);
}
[Fact]
public async void ListAccounts_All_Paged_Result__OK()
{
var repoAccountRepos = new Shared.Collections.RepoApiLib.Repositories.RepoAccountRepository(_dbContext);
//act
var result = await repoAccountRepos.ListAsync(new List<int?> { }, 0, 2, null, null, null, true);
// Assert
Assert.NotNull(result);
Assert.Equal(2,result.Items.Count());
Assert.Equal(2, result.Total);
}
[Fact]
public async void ListAccounts_All__OK()
{
var repoAccountRepos = new Shared.Collections.RepoApiLib.Repositories.RepoAccountRepository(_dbContext);
//act
var result = await repoAccountRepos.ListAsync(new List<int?> { }, 0, 10, null, null, null, true);
// Assert
Assert.NotNull(result);
Assert.Equal(2,result.Items.Count());
Assert.Equal(2, result.Total);
}
[Fact]
public async void SaveAccount_OK()
{
var options = new DbContextOptionsBuilder<AppDbContext>()
.UseInMemoryDatabase(Guid.NewGuid().ToString())
.Options;
var context = new AppDbContext(options);
var repoAccountRepos = new Shared.Collections.RepoApiLib.Repositories.RepoAccountRepository(context);
var repo = new RepoAccount()
{
AccountNo = "123456-789",
Balance = 1000,
Branch = 5,
Collector = "Test",
DaysDelinquent = 5,
AccountTypeCode = "L1",
LoanNo = 789,
DelinquentAmount = 500,
CurrentDelinquentAmount = 500,
LstPmtAmt = 200,
MemberNo = 123456,
OrigAmount = 1000,
O4RDate = DateTime.Today,
PrimaryIndividualId = "777777",
SubStatus = "XXX",
Status = "O4R",
Borrowers = new List<Borrower>()
{
new Borrower()
{
IndividualId = "77777",
IndividualName = "Test Borrower",
OwnershipType = 6
}
},
Collaterals = new List<Collateral>()
{
new Collateral()
{
BodyStyle = "Coupe",
Description = "2019 Subaru BRZ Ts",
Make = "Subaru",
Model = "BRZ",
Vin = "1234567AAAGHZJP11",
Year = 2019,
VehicleType = 1,
Inoperable = false
}
},
ReferenceId = 555,
AccountLastProcessed = DateTime.Today
};
Assert.Equal(0, repo.RepoId);
//act
var result = await repoAccountRepos.AddAsync(repo);
context.SaveChanges();
// Assert
Assert.NotNull(result);
Assert.NotNull(result.Collaterals);
Assert.NotNull(result.Borrowers);
Assert.NotEqual(0, result.RepoId);
Assert.NotEqual(0, result.Collaterals.First().CollateralId);
Assert.Equal(result.RepoId, result.Borrowers.First().RepoId);
Assert.Equal(result.RepoId, result.Collaterals.First().RepoId);
}
[Fact]
public async void UpdateAccount_OK()
{
var options = new DbContextOptionsBuilder<AppDbContext>()
.UseInMemoryDatabase(Guid.NewGuid().ToString())
.Options;
var context = new AppDbContext(options);
var repoAccountRepository = new Shared.Collections.RepoApiLib.Repositories.RepoAccountRepository(context);
var repo = new RepoAccount()
{
AccountNo = "123456-789",
Balance = 1000,
Branch = 5,
Collector = "Test",
DaysDelinquent = 5,
AccountTypeCode = "L1",
LoanNo = 789,
DelinquentAmount = 500,
CurrentDelinquentAmount = 500,
LstPmtAmt = 200,
OrigAmount = 1000,
O4RDate = DateTime.Today,
PrimaryIndividualId = "777777",
SubStatus = "XXX",
Status = "O4R",
Borrowers = new List<Borrower>()
{
new Borrower()
{
IndividualId = "77777",
IndividualName = "Test Borrower",
OwnershipType = 6
}
},
Collaterals = new List<Collateral>()
{
new Collateral()
{
BodyStyle = "Coupe",
Description = "2019 Subaru BRZ Ts",
Make = "Subaru",
Model = "BRZ",
Vin = "1234567AAAGHZJP11",
Year = 2019,
VehicleType = 1,
Inoperable = false,
RepoCompanySelections = new List<RepoCompanySelection>()
{
new RepoCompanySelection()
{
RepoCompanyId = 7,
DateTimeCreated = DateTime.Now,
RepoCompanyAssignmentDate = DateTime.Now,
RepoType = RepoType.Involuntary
}
}
}
},
ReferenceId = 999,
AccountLastProcessed = null
};
var result = await repoAccountRepository.AddAsync(repo);
context.SaveChanges();
// Assert
Assert.NotNull(result);
Assert.Equal("1000", result.Balance.ToString());
Assert.Equal(1, result.Collaterals.Count);
Assert.Equal(999, result.ReferenceId);
//act
result.Balance = 7299;
result.Collaterals.Add(new Collateral()
{
BodyStyle = "Coupe",
Description = "2019 Subaru BRZ Ts",
Make = "Subaru",
Model = "BRZ",
Vin = "1234567AAAGHZJP22",
Year = 2019,
VehicleType = 1,
Inoperable = false
});
result.AccountLastProcessed = DateTime.Now;
// repoAccountRepos.Update(result);
_dbContext.SaveChanges();
var resultNew = await repoAccountRepository.FindByIdAsync(result.RepoId);
// Assert
Assert.NotNull(resultNew);
Assert.NotNull(resultNew.AccountLastProcessed);
Assert.Equal("7299", resultNew.Balance.ToString());
Assert.Equal(2, resultNew.Collaterals.Count);
Assert.Equal(999, resultNew.ReferenceId);
}
}
}
@@ -0,0 +1,31 @@
using System;
using LCU.Shared.Collections.RepoApiLib.Persistence;
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
namespace LCU.API.Collections.RepoApiTests.Repository
{
public abstract class TestWithSqlite : IDisposable
{
private const string InMemoryConnectionString = "DataSource=:memory:";
private readonly SqliteConnection _connection;
protected readonly AppDbContext SqliteDbContext;
protected TestWithSqlite()
{
_connection = new SqliteConnection(InMemoryConnectionString);
_connection.Open();
var options = new DbContextOptionsBuilder<AppDbContext>()
.UseSqlite(_connection)
.Options;
SqliteDbContext = new AppDbContext(options);
SqliteDbContext.Database.EnsureCreated();
}
public void Dispose()
{
_connection.Close();
}
}
}
@@ -0,0 +1,608 @@
{
"repoAccounts": [
{
"repoId": 1,
"accountNo": "9987149147",
"status": "PSKP",
"memberNo": 3212321,
"loanNo": 147,
"accountTypeCode": "L-AC ",
"branch": 13,
"collector": " 1367",
"balance": 7238.03,
"dueToPayDate": "2019-08-02T00:00:00",
"o4RDate": "2019-10-21T09:01:47.383",
"dateFirstDelinquent": "2019-04-08T00:00:00",
"delinquentAmount": 3491.36,
"daysDelinquent": 80,
"paidSkipAmount": null,
"subStatus": "DE",
"requiredPaymentAmount": 449.03,
"currentDelinquentAmount": 3491.36,
"lstPmtAmt": 450.00,
"origAmount": 16594.79,
"lastPaymentDate": "2019-09-25T00:00:00",
"dateFirstIntellect": "2015-12-07T00:00:00",
"primaryIndividualId": "370556",
"bankruptcy": null,
"manualRedemptionDate": null,
"redemptionExpiredDate": null,
"borrowers": [
{
"repoId": 1,
"individualId": "370556",
"ownershipType": 6,
"individualName": "GEORGE WASHINGTON"
}
],
"collaterals": [
{
"collateralId": 1,
"repoId": 1,
"vin": "100000AB4FN591150",
"make": "CHRYSLER",
"model": "200",
"year": 2015,
"description": "2015 CHRYSLER 200",
"vehicleType": null,
"bodyStyle": null,
"inoperable": null,
"collateralTypeId": null,
"retitledInLandmarkName": null,
"refCollateralId": null,
"repoCompanySelections": [
{
"id": 1,
"collateralId": 1,
"repoType": "PreSkip",
"repoCompanyId": 1,
"repoCompanyAssignmentDate": "2019-10-21T05:00:00",
"dateRepoed": "2019-11-23T06:00:00",
"dateTimeCreated": "2019-11-04T15:22:43.883"
},
{
"id": 4433,
"collateralId": 1,
"repoType": "Skip",
"repoCompanyId": 5,
"repoCompanyAssignmentDate": "2019-11-23T12:00:00",
"dateRepoed": "2020-03-04T06:00:00",
"dateTimeCreated": "2019-11-25T11:40:46.33"
}
]
}
],
"repoStatusChanges": [
{
"id": 1,
"repoId": 1,
"statusFrom": "None",
"statusTo": "O4R",
"changedBy": "Importer",
"changedDate": "2019-10-21T09:01:47.43"
},
{
"id": 15564,
"repoId": 1,
"statusFrom": "O4R",
"statusTo": "PSKP",
"changedBy": "System User",
"changedDate": "2020-03-02T17:04:57.383"
}
],
"refundStatus": {
"repoId": 1,
"warrantyRefundStatus": null,
"insuranceRefundStatus": null,
"premiumDefiRefundStatus": null,
"cpiRefundStatus": "Received",
"refundsReceivedDate": null
},
"dateClosed": null
},
{
"repoId": 2,
"accountNo": "9726450144",
"status": "RECA",
"memberNo": 9726450,
"loanNo": 144,
"accountTypeCode": "L-P4 ",
"branch": 29,
"collector": " 5784",
"balance": 893.01,
"dueToPayDate": "2018-02-23T00:00:00",
"o4RDate": "2018-04-02T11:49:24.103",
"dateFirstDelinquent": "2017-11-28T00:00:00",
"delinquentAmount": 1233.48,
"daysDelinquent": 100,
"paidSkipAmount": null,
"subStatus": "BKCB",
"requiredPaymentAmount": 325.59,
"currentDelinquentAmount": 1233.48,
"lstPmtAmt": 189.12,
"origAmount": 16340.72,
"lastPaymentDate": "2019-01-23T00:00:00",
"dateFirstIntellect": "2014-01-28T00:00:00",
"primaryIndividualId": "336974",
"bankruptcy": "B13 ",
"manualRedemptionDate": null,
"redemptionExpiredDate": null,
"borrowers": [
{
"repoId": 2,
"individualId": "336974",
"ownershipType": 6,
"individualName": "JOHN WICK"
},
{
"repoId": 2,
"individualId": "738089",
"ownershipType": 3,
"individualName": "BRUCE WAYNE"
}
],
"collaterals": [
{
"collateralId": 2,
"repoId": 2,
"vin": "1FMCU90000KB11152",
"make": "FORD TRUCK",
"model": "Escape",
"year": 2009,
"description": "",
"vehicleType": null,
"bodyStyle": null,
"inoperable": null,
"collateralTypeId": null,
"retitledInLandmarkName": null,
"refCollateralId": null,
"repoCompanySelections": [
{
"id": 2,
"collateralId": 2,
"repoType": "Involuntary",
"repoCompanyId": 4,
"repoCompanyAssignmentDate": "2018-04-02T05:00:00",
"dateRepoed": "2018-04-09T05:00:00",
"dateTimeCreated": "2019-11-04T15:22:44.68"
}
]
}
],
"repoStatusChanges": [
{
"id": 2,
"repoId": 2,
"statusFrom": "None",
"statusTo": "O4R",
"changedBy": "Importer",
"changedDate": "2018-04-02T11:49:24.107"
},
{
"id": 3,
"repoId": 2,
"statusFrom": "O4R",
"statusTo": "RECA",
"changedBy": "Importer",
"changedDate": "2018-04-09T10:49:17.513"
}
],
"refundStatus": null,
"dateClosed": null,
"referenceId": 555
},
{
"repoId": 3,
"accountNo": "9725978-143",
"status": "PSKP",
"memberNo": 9725978,
"loanNo": 143,
"accountTypeCode": "L-AC ",
"branch": 27,
"collector": " 2700",
"balance": 4136.95,
"dueToPayDate": "2017-04-25T00:00:00",
"o4RDate": "2017-07-26T08:49:07.003",
"dateFirstDelinquent": "2017-03-30T00:00:00",
"delinquentAmount": 2663.64,
"daysDelinquent": 82,
"paidSkipAmount": null,
"subStatus": "PSKP",
"requiredPaymentAmount": 334.35,
"currentDelinquentAmount": null,
"lstPmtAmt": 280.00,
"origAmount": 10853.40,
"lastPaymentDate": "2017-05-05T00:00:00",
"dateFirstIntellect": "2014-04-30T00:00:00",
"primaryIndividualId": "705151",
"bankruptcy": null,
"manualRedemptionDate": null,
"redemptionExpiredDate": null,
"borrowers": [
{
"repoId": 3,
"individualId": "705151",
"ownershipType": 6,
"individualName": "CLARK KENT"
}
],
"collaterals": [
{
"collateralId": 3,
"repoId": 3,
"vin": "1J4GL00007W516801",
"make": "Jeep",
"model": "Liberty",
"year": 2007,
"description": "",
"vehicleType": null,
"bodyStyle": null,
"inoperable": null,
"collateralTypeId": null,
"retitledInLandmarkName": null,
"refCollateralId": null,
"repoCompanySelections": [
{
"id": 3,
"collateralId": 3,
"repoType": "Skip",
"repoCompanyId": 5,
"repoCompanyAssignmentDate": "2017-07-26T00:00:00",
"dateRepoed": null,
"dateTimeCreated": "2019-11-04T15:22:45.71"
}
]
}
],
"repoStatusChanges": [
{
"id": 4,
"repoId": 3,
"statusFrom": "None",
"statusTo": "O4R",
"changedBy": "Importer",
"changedDate": "2017-07-26T08:49:07.007"
},
{
"id": 5,
"repoId": 3,
"statusFrom": "O4R",
"statusTo": "PSKP",
"changedBy": "Importer",
"changedDate": "2017-12-20T14:49:07.78"
}
],
"refundStatus": {
"repoId": 3,
"warrantyRefundStatus": null,
"insuranceRefundStatus": null,
"premiumDefiRefundStatus": null,
"cpiRefundStatus": null,
"refundsReceivedDate": null
},
"dateClosed": "2017-12-20T14:49:07.78"
},
{
"repoId": 4,
"accountNo": "9723452144",
"status": "SOLD",
"memberNo": 9723452,
"loanNo": 144,
"accountTypeCode": "L-P1 ",
"branch": 27,
"collector": " 5737",
"balance": 14097.27,
"dueToPayDate": "2017-07-19T00:00:00",
"o4RDate": "2017-12-22T08:49:11.617",
"dateFirstDelinquent": "2017-08-24T00:00:00",
"delinquentAmount": 3523.20,
"daysDelinquent": 133,
"paidSkipAmount": null,
"subStatus": null,
"requiredPaymentAmount": 353.12,
"currentDelinquentAmount": null,
"lstPmtAmt": 200.00,
"origAmount": 14555.18,
"lastPaymentDate": "2018-02-05T00:00:00",
"dateFirstIntellect": "2016-12-24T00:00:00",
"primaryIndividualId": "703492",
"bankruptcy": null,
"manualRedemptionDate": null,
"redemptionExpiredDate": "2018-04-24T09:39:26",
"borrowers": [
{
"repoId": 4,
"individualId": "703492",
"ownershipType": 6,
"individualName": "Peter Parker"
}
],
"collaterals": [
{
"collateralId": 4,
"repoId": 4,
"vin": "1C3CDZA0000637598",
"make": "DODGE",
"model": "Avenger",
"year": 2013,
"description": "2013 DODGE",
"vehicleType": 0,
"bodyStyle": "4DHT",
"inoperable": false,
"collateralTypeId": 2,
"retitledInLandmarkName": "2018-04-27T11:37:37.283",
"refCollateralId": null,
"repoCompanySelections": [
{
"id": 4,
"collateralId": 4,
"repoType": "Skip",
"repoCompanyId": 5,
"repoCompanyAssignmentDate": "2017-12-22T00:00:00",
"dateRepoed": "2018-04-09T09:49:09.817",
"dateTimeCreated": "2019-11-04T15:22:46.89"
}
]
}
],
"repoStatusChanges": [
{
"id": 6,
"repoId": 4,
"statusFrom": "None",
"statusTo": "O4R",
"changedBy": "Importer",
"changedDate": "2017-12-22T08:49:11.617"
},
{
"id": 7,
"repoId": 4,
"statusFrom": "O4R",
"statusTo": "REPO",
"changedBy": "Importer",
"changedDate": "2018-04-09T09:49:09.997"
},
{
"id": 8,
"repoId": 4,
"statusFrom": "REPO",
"statusTo": "SOLD",
"changedBy": "Diana V",
"changedDate": "2018-05-12T10:09:49.393"
}
],
"refundStatus": {
"repoId": 4,
"warrantyRefundStatus": null,
"insuranceRefundStatus": null,
"premiumDefiRefundStatus": null,
"cpiRefundStatus": null,
"refundsReceivedDate": null
},
"dateClosed": "2018-05-12T10:09:49.393"
}
],
"auctionAssignments": [
{
"id": 3075,
"auctionId": "1259",
"repoId": 2,
"auctionCustomerNo": "542673-143",
"collateralVIN": "1FMCU9E000CKC25751",
"dateSubmitted": "2020-05-07T11:48:45.773",
"floorPrice": null,
"floorPriceResponseCode": null,
"floorPriceResponseDescription": null,
"floorPriceSubmissionErrors": null,
"holdStatus": null,
"holdUntil": null,
"redeemedDate": null,
"vehicleType": null,
"bodyStyle": null,
"inoperable": null,
"retailValue": null,
"auctionNotes": null,
"availablePickupDate": "2020-05-07T05:00:00",
"legalSaleDate": "2020-05-22T15:00:00",
"cleaningLevel": 3,
"submissionResponseCode": null,
"submissionResponseDescription": null,
"submissionErrors": null,
"sentTitleDocsDate": null,
"titleSentResponseCode": null,
"titleSentResponseDescription": null,
"titleSentSubmissionErrors": null,
"addedThroughRepoDatabase": null,
"isActive": true,
"autoIMS": {
"repoId": 2,
"vin": "1FMCU9EG6CKC25751",
"auctionAssignmentId": 3075,
"auctionCustomerNo": "542673-143",
"assignmentAccepted": null,
"dateReceivedFromAutoIMS": "2020-05-07T12:45:14.483",
"scheduledSaleDate": null,
"soldDate": null,
"announcedConditions": "",
"arbitrationReason": "",
"asIs100KMiles": false,
"auctionAge": null,
"auctionGuideBookPrice": null,
"buyerId": "",
"buyerName": "",
"chargeAmount": null,
"checkAmount": null,
"clientAge": 0,
"clientCancelled": null,
"collisionDamage": "",
"inspectedDate": null,
"dateofLoss": null,
"datePickedUp": null,
"dateEnteredAutoIMS": "2020-05-07T12:48:00",
"daysRun": null,
"daysRunHighestBidRecordedbyAuction": "",
"daystoDelivery": null,
"description": "1FMCU9EG6CKC25751 2012 FORD TRUCK Escape 4SUV",
"isDrivable": null,
"floorPriceAccepted": null,
"fundsSent": null,
"grossPercentFloor": 0.00,
"highestBid": null,
"statedMileage": null,
"netPercentFloor": 0.00,
"otherAdvanceFees": null,
"otherTotal": "",
"otherAdvancedOther": "",
"otherAdvancedStorage": "",
"otherAdvancedTow": "",
"otherMiscellaneous": "",
"salePrice": null,
"titleNumber": "",
"titleReceived": null,
"titleReturned": null,
"titleState": "",
"titleStatus": "Title Not Sent",
"titleStatusfromAuction": "",
"totalCharges": null,
"approvedVehicleGrade": null,
"isOperable": false,
"shipmentDate": null,
"status": "Assigned for Pickup",
"storageCost": null,
"storageRatePerDay": null,
"towCost": null,
"vehicleDecimalGradeCode": null,
"vehicleGrade": null,
"mmrNationalAdjustedPrice": null,
"mmrRegionalAdjustedPrice": null,
"mmr": null,
"conditionReportLink": "http://Ecr.autoims.com/jsp/ConditionReport.jsp?clientid=LAND&iid=4d085a8af1c49a9996cdc8f318559314",
"collateralImagePath": null
},
"auction": {
"auctionID": "1259",
"name": "Wisconsin State Auto Auction",
"active": "yes",
"address_Line_1": "Road Drive",
"address_Line_2": "-",
"city": "Small Town",
"state": "WI",
"zip": "532000",
"country": "USA",
"phone": "(920)100-0000",
"fax": "(920)100-0000",
"latitude": 43.6101220000000,
"longitude": -88.4395370000000
},
"auctionAssignmentToCollaterals": [
{
"auctionAssignmentId": 3075,
"collateralId": 4932,
"collateral": {
"collateralId": 4932,
"repoId": 2,
"vin": "1FMCU9EG6CKC25751",
"make": "FORD TRUCK",
"model": "Escape",
"year": 2012,
"description": "2012 FORD TRUCK",
"vehicleType": null,
"bodyStyle": "Utility 4D Limited 4WD V",
"inoperable": null,
"collateralTypeId": null,
"retitledInLandmarkName": null,
"refCollateralId": "676426",
"repoCompanySelections": null
}
}
],
"floorPriceValuesUsed": null
}
],
"eventAlerts": [
{
"RepoId": 14883,
"AccountNo": "9987149147",
"Message": "test",
"CreatedBy": "Unit Test",
"DateAdded": "2019-06-27T00:00:00"
},
{
"RepoId": 14883,
"AccountNo": "9987149147",
"Message": "test",
"CreatedBy": "Unit Test",
"DateAdded": "2019-06-27T00:00:00",
"DateMarkedRead": "2019-06-27T00:00:00",
"MarkedReadBy": "tester"
},
{
"RepoId": 11688,
"AccountNo": "6829620-143",
"Message": "test",
"CreatedBy": "Unit Test",
"DateAdded": "2019-06-27T00:00:00",
"DateMarkedRead": "2019-06-27T00:00:00",
"MarkedReadBy": "tester"
},
{
"RepoId": 11688,
"AccountNo": "6829620-143",
"Message": "Payment Received",
"CreatedBy": "Unit Test",
"DateAdded": "2019-06-27T00:00:00",
"DateMarkedRead": "2019-06-27T00:00:00",
"MarkedReadBy": "tester"
}
],
"repoManualStatus": [
{
"ID": 1,
"Description": "PSKP",
"IsActiveStatus": false,
"WatchForStatusChanges": false
},
{
"ID": 2,
"Description": "NOT ACTIVE",
"IsActiveStatus": false,
"WatchForStatusChanges": false
},
{
"ID": 3,
"Description": "SOLD",
"IsActiveStatus": false,
"WatchForStatusChanges": false
},
{
"ID": 4,
"Description": "REDEEMED",
"IsActiveStatus": false,
"WatchForStatusChanges": true
},
{
"ID": 5,
"Description": "O4R",
"IsActiveStatus": true,
"WatchForStatusChanges": true
},
{
"ID": 6,
"Description": "REPO",
"IsActiveStatus": true,
"WatchForStatusChanges": true
},
{
"ID": 7,
"Description": "RECA",
"IsActiveStatus": true,
"WatchForStatusChanges": true
},
{
"ID": 8,
"Description": "REHO",
"IsActiveStatus": true,
"WatchForStatusChanges": true
}
]
}