using System.Collections.Generic; using System.Linq; using LCU.API.Collections.RepoApi.Domain.FloorPricing; using LCU.API.Collections.RepoApi.Domain.FloorPricing.Strategies; using LCU.API.Collections.RepoApi.Services; using LCU.Shared.Collections.RepoApiLib.Models; using LCU.Shared.Collections.RepoApiLib.WebServices.NADA; using Moq; using Xunit; namespace LCU.API.Collections.RepoApiTests.Services { public class FloorPricingServiceTest { private readonly Mock mockFloorPriceService; private readonly Mock mockCollateralValueService; private readonly Mock mockImsAutoFileDataService; private readonly Mock mockStrategyFactory; private readonly FloorPricingService service; public FloorPricingServiceTest() { mockFloorPriceService = new Mock(); mockCollateralValueService = new Mock(); mockImsAutoFileDataService = new Mock(); mockStrategyFactory = new Mock(); service = new FloorPricingService( mockStrategyFactory.Object, mockFloorPriceService.Object, mockImsAutoFileDataService.Object, mockCollateralValueService.Object); } [Fact] public void Full_Calculate_Floor_Price_OK() { // arrange var strategies = new List() { new AutoImsSuggestedValue(), new NadaMmrConditionValue() }; FloorPriceCalculationParams fpcParams = new FloorPriceCalculationParams(); mockStrategyFactory.Setup(x => x.GetFloorPricingStrategies()).Returns(strategies); // act var results = service.GetCalculatedFloorPrices(fpcParams); // Assert Assert.NotNull(results); Assert.True(results.Any()); } [Fact] public void Select_Floor_Price_OK() { // arrange List results = new List() { new FloorPriceCalculationResult() { Success = true, FloorPrice = 1000, StrategyName = "a", ResultWeight = 100 }, new FloorPriceCalculationResult() { Success = false, FloorPrice = 0, StrategyName = "b", ResultWeight = 1001 }, new FloorPriceCalculationResult() { Success = true, FloorPrice = 0, StrategyName = "c", ResultWeight = -1 }, new FloorPriceCalculationResult() { Success = true, FloorPrice = 1200, StrategyName = "d", ResultWeight = 101 } }; var strategies = new List() { new AutoImsSuggestedValue(), new NadaMmrConditionValue() }; mockStrategyFactory.Setup(x => x.GetFloorPricingStrategies()).Returns(strategies); // act var result = service.SelectBestFloorPrice(results); // Assert Assert.NotNull(result); Assert.Equal(1200, result.FloorPrice); } [Fact] public void Failed_NADA_Soap_Request_CollateralValuation_Not_Null() { mockCollateralValueService.Setup(x => x.GetCollateralValue("", 0, 0)).Throws(); var results = service.GetCollateralValuation("",0,0); Assert.NotNull(results); } } }