Files
2026-04-20 14:47:24 -05:00

295 lines
10 KiB
C#

using System.Collections.Generic;
using LCU.API.Collections.RepoApi.Domain.AlertChecker;
using LCU.API.Collections.RepoApi.Domain.Processing;
using LCU.Shared.Collections.RepoApiLib.Models;
using Xunit;
namespace LCU.API.Collections.RepoApiTests.AlertCheckers
{
public class AuctionVinDifferentCheckerTest
{
readonly AuctionVinDifferentChecker _auctionVinDifferentChecker;
public AuctionVinDifferentCheckerTest()
{
_auctionVinDifferentChecker = new AuctionVinDifferentChecker();
}
[Fact]
public void Auction_Vin_Different_Single_Created_Ok()
{
var updatedAccount = new RepoAccount()
{
Collaterals = new List<Collateral>()
{
new Collateral()
{
AuctionAssignmentToCollaterals = new List<AuctionAssignmentToCollateral>()
{
new AuctionAssignmentToCollateral()
{
AuctionAssignmentId = 1,
CollateralId = 1
}
},
Vin = "OurVin"
}
}
};
var slip = new RepoAccountProcessingSlip()
{
AuctionAssignments = new List<AuctionAssignment>()
{
new AuctionAssignment()
{
AutoIMS = new ImsAutoFileData()
{
VIN = "TheirVin"
}
}
},
ExistingRepoAccount = new RepoAccount(),
UpdatedRepoAccount = updatedAccount
};
var result = _auctionVinDifferentChecker.CheckForAlert(slip);
Assert.NotNull(result);
Assert.Equal("Auction VIN Different", result[0].Message);
Assert.Equal("Auction Assignment VIN: THEIRVIN differs from RepoManager VIN: OURVIN", result[0].SubMessage);
}
[Fact]
public void Auction_Vin_Different_Multiple_Created_Ok()
{
var updatedAccount = new RepoAccount()
{
Collaterals = new List<Collateral>()
{
new Collateral()
{
AuctionAssignmentToCollaterals = new List<AuctionAssignmentToCollateral>()
{
new AuctionAssignmentToCollateral()
{
AuctionAssignmentId = 1,
CollateralId = 1
}
},
Vin = "OurFirstVin"
},
new Collateral()
{
AuctionAssignmentToCollaterals = new List<AuctionAssignmentToCollateral>()
{
new AuctionAssignmentToCollateral()
{
AuctionAssignmentId = 1,
CollateralId = 1
}
},
Vin = "OurSecondVin"
},
new Collateral()
{
AuctionAssignmentToCollaterals = new List<AuctionAssignmentToCollateral>()
{
new AuctionAssignmentToCollateral()
{
AuctionAssignmentId = 1,
CollateralId = 1
}
},
Vin = "OurThirdVin"
}
}
};
var slip = new RepoAccountProcessingSlip()
{
AuctionAssignments = new List<AuctionAssignment>()
{
new AuctionAssignment()
{
AutoIMS = new ImsAutoFileData()
{
VIN = "TheirVin"
}
}
},
ExistingRepoAccount = new RepoAccount(),
UpdatedRepoAccount = updatedAccount
};
var result = _auctionVinDifferentChecker.CheckForAlert(slip);
Assert.NotNull(result);
Assert.Equal("Auction VIN Different", result[0].Message);
Assert.Equal(
"Auction Assignment VIN: THEIRVIN is not among RepoManager VINs: OURFIRSTVIN, OURSECONDVIN, OURTHIRDVIN",
result[0].SubMessage);
}
[Fact]
public void Auction_Vin_Different_Not_Created_Single_Vins_Match()
{
var updatedAccount = new RepoAccount()
{
Collaterals = new List<Collateral>()
{
new Collateral()
{
AuctionAssignmentToCollaterals = new List<AuctionAssignmentToCollateral>()
{
new AuctionAssignmentToCollateral()
{
AuctionAssignmentId = 1,
CollateralId = 1
}
},
Vin = "OurVin"
}
}
};
var slip = new RepoAccountProcessingSlip()
{
AuctionAssignments = new List<AuctionAssignment>()
{
new AuctionAssignment()
{
AutoIMS = new ImsAutoFileData()
{
VIN = "OurVin"
}
}
},
ExistingRepoAccount = new RepoAccount(),
UpdatedRepoAccount = updatedAccount
};
var result = _auctionVinDifferentChecker.CheckForAlert(slip);
Assert.Null(result);
}
[Fact]
public void Auction_Vin_Different_Not_Created_Multiple_Vins_Match()
{
var updatedAccount = new RepoAccount()
{
Collaterals = new List<Collateral>()
{
new Collateral()
{
AuctionAssignmentToCollaterals = new List<AuctionAssignmentToCollateral>()
{
new AuctionAssignmentToCollateral()
{
AuctionAssignmentId = 1,
CollateralId = 1
}
},
Vin = "OurFirstVin"
},
new Collateral()
{
AuctionAssignmentToCollaterals = new List<AuctionAssignmentToCollateral>()
{
new AuctionAssignmentToCollateral()
{
AuctionAssignmentId = 1,
CollateralId = 1
}
},
Vin = "OurSecondVin"
}
}
};
var slip = new RepoAccountProcessingSlip()
{
AuctionAssignments = new List<AuctionAssignment>()
{
new AuctionAssignment()
{
AutoIMS = new ImsAutoFileData()
{
VIN = "OurSecondVin"
}
}
},
ExistingRepoAccount = new RepoAccount(),
UpdatedRepoAccount = updatedAccount
};
var result = _auctionVinDifferentChecker.CheckForAlert(slip);
Assert.Null(result);
}
[Fact]
public void Auction_Vin_Different_Not_Created_Vin_Null()
{
var updatedAccount = new RepoAccount()
{
Collaterals = new List<Collateral>()
{
new Collateral()
{
AuctionAssignmentToCollaterals = new List<AuctionAssignmentToCollateral>()
{
new AuctionAssignmentToCollateral()
{
AuctionAssignmentId = 1,
CollateralId = 1
}
},
Vin = "OurVin"
}
}
};
var slip = new RepoAccountProcessingSlip()
{
AuctionAssignments = new List<AuctionAssignment>()
{
new AuctionAssignment()
{
AutoIMS = new ImsAutoFileData()
}
},
ExistingRepoAccount = new RepoAccount(),
UpdatedRepoAccount = updatedAccount
};
var result = _auctionVinDifferentChecker.CheckForAlert(slip);
Assert.Null(result);
}
[Fact]
public void Auction_Vin_Different_Not_Created_No_AuctionAssignments()
{
var updatedAccount = new RepoAccount()
{
Collaterals = new List<Collateral>()
{
new Collateral()
}
};
var slip = new RepoAccountProcessingSlip()
{
AuctionAssignments = new List<AuctionAssignment>()
{
new AuctionAssignment()
{
AutoIMS = new ImsAutoFileData()
}
},
ExistingRepoAccount = new RepoAccount(),
UpdatedRepoAccount = updatedAccount
};
var result = _auctionVinDifferentChecker.CheckForAlert(slip);
Assert.Null(result);
}
}
}