Files
monorepo/LCU.API.Collections.RepoApi-old/LCU.API.Collections.RepoApiTests/Services/AuctionReportingServiceTest.cs
T
2026-04-20 14:47:24 -05:00

472 lines
20 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using LCU.API.Collections.RepoApi.Models.Requests;
using LCU.API.Collections.RepoApi.Services.Reporting;
using LCU.Shared.Collections.RepoApiLib.Models.Reporting;
using LCU.Shared.Collections.RepoApiLib.Repositories;
using Moq;
using Xunit;
namespace LCU.API.Collections.RepoApiTests.Services
{
public class AuctionReportingServiceTest
{
private IAuctionReportingService _auctionReportingService;
private Mock<IReportingRepository> _mockReportingRepository;
public AuctionReportingServiceTest()
{
_mockReportingRepository = new Mock<IReportingRepository>();
_auctionReportingService = new AuctionReportingService(_mockReportingRepository.Object);
}
[Fact]
public async void Empty_Result_Set_Ok()
{
// arrange
var rawResults = new List<StdReportEntry>() { };
_mockReportingRepository.Setup(x => x.GetAccountsByDateRepoed(It.IsAny<DateTime>(), It.IsAny<DateTime>()))
.ReturnsAsync(rawResults);
var request = new ReportingRequest();
// act
var result = await _auctionReportingService.GetAssignedBalance(request.LowDate, request.HighDate);
// assert
Assert.NotNull(result);
}
[Fact]
public async void GrossAmount_Two_Month_Set_Ok()
{
// arrange - should produce 4 rows with 3 columns... 2 months + total for columns and totals, two auctions, and null auctions row.
var rawResults = new List<StdReportEntry>()
{
new StdReportEntry()
{
RepoId = 1000,
AuctionId = "A1",
AuctionName = "Ted",
AccountNo = "123456-789",
Balance = 1000,
CollateralId = 100,
DateRepoed = DateTime.Parse("12/15/2019"),
RepoCompanyId = 400,
DateEnteredAutoIMS = DateTime.Parse("10/01/2019")
},
new StdReportEntry()
{
RepoId = 1001,
AuctionId = "A2",
AuctionName = "Tiger",
AccountNo = "234561-789",
Balance = 500,
CollateralId = 101,
DateRepoed = DateTime.Parse("11/15/2019"),
RepoCompanyId = 500,
DateEnteredAutoIMS = DateTime.Parse("10/01/2019")
},
new StdReportEntry()
{
RepoId = 1001,
AuctionId = "A2",
AuctionName = "Tiger",
AccountNo = "234561-789",
Balance = 500,
CollateralId = 102,
DateRepoed = DateTime.Parse("11/15/2019"),
RepoCompanyId = 500,
DateEnteredAutoIMS = DateTime.Parse("10/01/2019")
},
new StdReportEntry()
{
RepoId = 1002,
AuctionId = "A1",
AuctionName = "Ted",
AccountNo = "345612-789",
Balance = 500,
CollateralId = 102,
DateRepoed = DateTime.Parse("11/15/2019"),
RepoCompanyId = 500,
DateEnteredAutoIMS = DateTime.Parse("10/01/2019")
}
};
_mockReportingRepository.Setup(x => x.GetAccountsByDateRepoed(It.IsAny<DateTime>(), It.IsAny<DateTime>()))
.ReturnsAsync(rawResults);
var highDate = DateTime.Parse("12/31/2019");
var lowDate = DateTime.Parse("11/01/2019");
var request = new ReportingRequest()
{
HighDate = highDate,
LowDate = lowDate
};
// act
var result = await _auctionReportingService.GetAssignedBalance(request.LowDate, request.HighDate);
// assert
Assert.NotNull(result);
Assert.Equal(4, result.DataTable.Rows.Count());
Assert.Equal(16, result.ReportTable.Cells.Length); // 4 rows of 4.
Assert.Equal("Ted", result.ReportTable.Cells[1, 0].Display);
Assert.Equal("$1,000.00", result.ReportTable.Cells[0, 1].Display);
Assert.Equal("$1,000.00", result.ReportTable.Cells[0, 2].Display);
Assert.Equal("$2,000.00", result.ReportTable.Cells[0, 3].Display);
Assert.Equal("-", result.ReportTable.Cells[3, 3].Display);
}
[Fact]
public async void GetActiveInventoryCountAtAuction_Two_Month_Set_Ok()
{
// arrange - should produce 4 rows with 3 columns... 2 months + total for columns and totals, two auctions, and null auctions row.
var rawResults = new List<StdReportEntry>()
{
new StdReportEntry()
{
RepoId = 1,
AuctionName = "Ted",
DateRepoed = DateTime.Parse("12/15/2019"),
},
new StdReportEntry()
{
RepoId = 2,
AuctionName = "Tiger",
DateRepoed = DateTime.Parse("11/15/2019"),
},
new StdReportEntry()
{
RepoId = 3,
AuctionName = "Tiger",
DateRepoed = DateTime.Parse("11/15/2019"),
},
new StdReportEntry()
{
RepoId = 4,
AuctionName = "Ted",
DateRepoed = DateTime.Parse("11/15/2019"),
}
};
_mockReportingRepository.Setup(x => x.GetAccountsByDateRepoed(It.IsAny<DateTime>(), It.IsAny<DateTime>()))
.ReturnsAsync(rawResults);
var highDate = DateTime.Parse("12/31/2019");
var lowDate = DateTime.Parse("11/01/2019");
var request = new ReportingRequest()
{
HighDate = highDate,
LowDate = lowDate
};
// act
var result = await _auctionReportingService.GetAssignedCollateralCount(request.LowDate, request.HighDate);
// assert
Assert.NotNull(result);
Assert.Equal(4, result.DataTable.Rows.Count());
Assert.Equal(16, result.ReportTable.Cells.Length); // 4 rows of 4.
// Assert Display
Assert.Equal("All Auctions", result.ReportTable.Cells[0, 0].Display);
Assert.Equal("3", result.ReportTable.Cells[0, 1].Display);
Assert.Equal("1", result.ReportTable.Cells[0, 2].Display);
Assert.Equal("4", result.ReportTable.Cells[0, 3].Display);
Assert.Equal("Ted", result.ReportTable.Cells[1, 0].Display);
Assert.Equal("1", result.ReportTable.Cells[1, 1].Display);
Assert.Equal("1", result.ReportTable.Cells[1, 2].Display);
Assert.Equal("2", result.ReportTable.Cells[1, 3].Display);
Assert.Equal("Tiger", result.ReportTable.Cells[2, 0].Display);
Assert.Equal("2", result.ReportTable.Cells[2, 1].Display);
Assert.Equal("-", result.ReportTable.Cells[2, 2].Display);
Assert.Equal("2", result.ReportTable.Cells[2, 3].Display);
Assert.Equal("No Auctions", result.ReportTable.Cells[3, 0].Display);
Assert.Equal("-", result.ReportTable.Cells[3, 1].Display);
Assert.Equal("-", result.ReportTable.Cells[3, 2].Display);
Assert.Equal("-", result.ReportTable.Cells[3, 3].Display);
}
[Fact]
public async void GetSoldPriceReport_Two_Month_Set_Ok()
{
// arrange - should produce 4 rows with 3 columns... 2 months + total for columns and totals, two auctions, and null auctions row.
var rawResults = new List<StdReportEntry>()
{
new StdReportEntry()
{
AuctionName = "Ted",
RepoId = 1,
SoldDate = DateTime.Parse("11/15/2019"),
GrossSalePrice = 1500
},
new StdReportEntry()
{
AuctionName = "Tiger",
RepoId = 2,
SoldDate = DateTime.Parse("11/10/2019"),
GrossSalePrice = 500
},
new StdReportEntry()
{
AuctionName = "Tiger",
RepoId = 3,
SoldDate = DateTime.Parse("11/20/2019"),
GrossSalePrice = 1000
},
new StdReportEntry()
{
AuctionName = "Ted",
RepoId = 4,
SoldDate = DateTime.Parse("12/02/2019"),
GrossSalePrice = 3500
}
};
_mockReportingRepository.Setup(x => x.GetAccountsByDateSoldInAutoIMS(It.IsAny<DateTime>(), It.IsAny<DateTime>()))
.ReturnsAsync(rawResults);
var highDate = DateTime.Parse("12/31/2019");
var lowDate = DateTime.Parse("11/01/2019");
var request = new ReportingRequest()
{
HighDate = highDate,
LowDate = lowDate
};
// act
var result = await _auctionReportingService.GetSalePriceReport(request.LowDate, request.HighDate);
// assert
Assert.NotNull(result);
Assert.Equal(4, result.DataTable.Rows.Count());
Assert.Equal(12, result.ReportTable.Cells.Length); // 3 rows of 4.
// Assert Display
Assert.Equal("All Auctions", result.ReportTable.Cells[0, 0].Display);
Assert.Equal("$3,000.00", result.ReportTable.Cells[0, 1].Display);
Assert.Equal("$3,500.00", result.ReportTable.Cells[0, 2].Display);
Assert.Equal("$6,500.00", result.ReportTable.Cells[0, 3].Display);
Assert.Equal("Ted", result.ReportTable.Cells[1, 0].Display);
Assert.Equal("$1,500.00", result.ReportTable.Cells[1, 1].Display);
Assert.Equal("$3,500.00", result.ReportTable.Cells[1, 2].Display);
Assert.Equal("$5,000.00", result.ReportTable.Cells[1, 3].Display);
Assert.Equal("Tiger", result.ReportTable.Cells[2, 0].Display);
Assert.Equal("$1,500.00", result.ReportTable.Cells[2, 1].Display);
Assert.Equal("-", result.ReportTable.Cells[2, 2].Display);
Assert.Equal("$1,500.00", result.ReportTable.Cells[2, 3].Display);
}
[Fact]
public async void GetAuctionFeeReport_Two_Month_Set_Ok()
{
// arrange - should produce 4 rows with 3 columns... 2 months + total for columns and totals, two auctions, and null auctions row.
var rawResults = new List<StdReportEntry>()
{
new StdReportEntry()
{
AuctionName = "Ted",
RepoId = 1,
SoldDate = DateTime.Parse("11/15/2019"),
TotalCharges = 250
},
new StdReportEntry()
{
AuctionName = "Tiger",
RepoId = 2,
SoldDate = DateTime.Parse("11/10/2019"),
TotalCharges = 150
},
new StdReportEntry()
{
AuctionName = "Tiger",
RepoId = 3,
SoldDate = DateTime.Parse("11/20/2019"),
TotalCharges = 350
},
new StdReportEntry()
{
AuctionName = "Ted",
RepoId = 4,
SoldDate = DateTime.Parse("12/02/2019"),
TotalCharges = 750
}
};
_mockReportingRepository.Setup(x => x.GetAccountsByDateSoldInAutoIMS(It.IsAny<DateTime>(), It.IsAny<DateTime>()))
.ReturnsAsync(rawResults);
var highDate = DateTime.Parse("12/31/2019");
var lowDate = DateTime.Parse("11/01/2019");
var request = new ReportingRequest()
{
HighDate = highDate,
LowDate = lowDate
};
// act
var result = await _auctionReportingService.GetAuctionFeeReport(request.LowDate, request.HighDate);
// assert
Assert.NotNull(result);
Assert.Equal(4, result.DataTable.Rows.Count());
Assert.Equal(12, result.ReportTable.Cells.Length); // 3 rows of 4.
// Assert Display
Assert.Equal("All Auctions", result.ReportTable.Cells[0, 0].Display);
Assert.Equal("$750.00", result.ReportTable.Cells[0, 1].Display);
Assert.Equal("$750.00", result.ReportTable.Cells[0, 2].Display);
Assert.Equal("$1,500.00", result.ReportTable.Cells[0, 3].Display);
Assert.Equal("Ted", result.ReportTable.Cells[1, 0].Display);
Assert.Equal("$250.00", result.ReportTable.Cells[1, 1].Display);
Assert.Equal("$750.00", result.ReportTable.Cells[1, 2].Display);
Assert.Equal("$1,000.00", result.ReportTable.Cells[1, 3].Display);
Assert.Equal("Tiger", result.ReportTable.Cells[2, 0].Display);
Assert.Equal("$500.00", result.ReportTable.Cells[2, 1].Display);
Assert.Equal("-", result.ReportTable.Cells[2, 2].Display);
Assert.Equal("$500.00", result.ReportTable.Cells[2, 3].Display);
}
[Fact]
public async void GetAvgDaysAssignedToSold_Two_Month_Set_Ok()
{
// arrange - should produce 4 rows with 3 columns... 2 months + total for columns and totals, two auctions, and null auctions row.
var rawResults = new List<StdReportEntry>()
{
new StdReportEntry()
{
AuctionName = "Ted",
RepoId = 1,
DateEnteredAutoIMS = DateTime.Parse("11/05/2019"),
SoldDate = DateTime.Parse("11/15/2019"),
},
new StdReportEntry()
{
AuctionName = "Tiger",
RepoId = 2,
DateEnteredAutoIMS = DateTime.Parse("11/05/2019"),
SoldDate = DateTime.Parse("11/10/2019"),
},
new StdReportEntry()
{
AuctionName = "Tiger",
RepoId = 3,
DateEnteredAutoIMS = DateTime.Parse("11/05/2019"),
SoldDate = DateTime.Parse("11/20/2019"),
},
new StdReportEntry()
{
AuctionName = "Ted",
RepoId = 4,
DateEnteredAutoIMS = DateTime.Parse("12/01/2019"),
SoldDate = DateTime.Parse("12/02/2019"),
}
};
_mockReportingRepository.Setup(x => x.GetAccountsByDateSoldInAutoIMS(It.IsAny<DateTime>(), It.IsAny<DateTime>()))
.ReturnsAsync(rawResults);
var highDate = DateTime.Parse("12/31/2019");
var lowDate = DateTime.Parse("11/01/2019");
var request = new ReportingRequest()
{
HighDate = highDate,
LowDate = lowDate
};
// act
var result = await _auctionReportingService.GetAvgDaysAssignedToSold(request.LowDate, request.HighDate);
// assert
Assert.NotNull(result);
Assert.Equal(4, result.DataTable.Rows.Count());
Assert.Equal(12, result.ReportTable.Cells.Length); // 3 rows of 4.
// Assert Display
Assert.Equal("All Auctions", result.ReportTable.Cells[0, 0].Display);
Assert.Equal("10", result.ReportTable.Cells[0, 1].Display);
Assert.Equal("1", result.ReportTable.Cells[0, 2].Display);
Assert.Equal("8", result.ReportTable.Cells[0, 3].Display);
Assert.Equal("Ted", result.ReportTable.Cells[1, 0].Display);
Assert.Equal("10", result.ReportTable.Cells[1, 1].Display);
Assert.Equal("1", result.ReportTable.Cells[1, 2].Display);
Assert.Equal("6", result.ReportTable.Cells[1, 3].Display);
Assert.Equal("Tiger", result.ReportTable.Cells[2, 0].Display);
Assert.Equal("10", result.ReportTable.Cells[2, 1].Display);
Assert.Equal("-", result.ReportTable.Cells[2, 2].Display);
Assert.Equal("10", result.ReportTable.Cells[2, 3].Display);
}
[Fact]
public async void GetAvgNetOfFloor_Two_Month_Set_Ok()
{
// arrange - should produce 4 rows with 3 columns... 2 months + total for columns and totals, two auctions, and null auctions row.
var rawResults = new List<StdReportEntry>()
{
new StdReportEntry()
{
AuctionName = "Ted",
RepoId = 1,
NetPercentFloor = 110,
SoldDate = DateTime.Parse("11/15/2019"),
},
new StdReportEntry()
{
AuctionName = "Tiger",
RepoId = 2,
NetPercentFloor = 80,
SoldDate = DateTime.Parse("11/10/2019"),
},
new StdReportEntry()
{
AuctionName = "Tiger",
RepoId = 3,
NetPercentFloor = 99.28m,
SoldDate = DateTime.Parse("11/20/2019"),
},
new StdReportEntry()
{
AuctionName = "Ted",
RepoId = 4,
NetPercentFloor = 45,
SoldDate = DateTime.Parse("12/02/2019"),
}
};
_mockReportingRepository.Setup(x => x.GetAccountsByDateSoldInAutoIMS(It.IsAny<DateTime>(), It.IsAny<DateTime>()))
.ReturnsAsync(rawResults);
var highDate = DateTime.Parse("12/31/2019");
var lowDate = DateTime.Parse("11/01/2019");
var request = new ReportingRequest()
{
HighDate = highDate,
LowDate = lowDate
};
// act
var result = await _auctionReportingService.GetAvgNetOfFloor(request.LowDate, request.HighDate);
// assert
Assert.NotNull(result);
Assert.Equal(4, result.DataTable.Rows.Count());
Assert.Equal(12, result.ReportTable.Cells.Length); // 3 rows of 4.
// Assert Display
Assert.Equal("All Auctions", result.ReportTable.Cells[0, 0].Display);
Assert.Equal("96.43 %", result.ReportTable.Cells[0, 1].Display);
Assert.Equal("45.00 %", result.ReportTable.Cells[0, 2].Display);
Assert.Equal("83.57 %", result.ReportTable.Cells[0, 3].Display);
Assert.Equal("Ted", result.ReportTable.Cells[1, 0].Display);
Assert.Equal("110.00 %", result.ReportTable.Cells[1, 1].Display);
Assert.Equal("45.00 %", result.ReportTable.Cells[1, 2].Display);
Assert.Equal("77.50 %", result.ReportTable.Cells[1, 3].Display);
Assert.Equal("Tiger", result.ReportTable.Cells[2, 0].Display);
Assert.Equal("89.64 %", result.ReportTable.Cells[2, 1].Display);
Assert.Equal("-", result.ReportTable.Cells[2, 2].Display);
Assert.Equal("89.64 %", result.ReportTable.Cells[2, 3].Display);
}
}
}