92 lines
3.2 KiB
C#
92 lines
3.2 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using LCU.API.Collections.RepoApi.Controllers;
|
|
using LCU.API.Collections.RepoApi.Services;
|
|
using LCU.Shared.Collections.RepoApiLib.Models;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Moq;
|
|
using Xunit;
|
|
|
|
namespace LCU.API.Collections.RepoApiTests.Controllers
|
|
{
|
|
public class VehicleFloorPricingParametersControllerTest
|
|
{
|
|
// Get tests
|
|
[Fact]
|
|
public async void Get_OK()
|
|
{
|
|
var mockService = new Mock<IVehicleFloorPricingParametersService>();
|
|
var mockHttpContextAccessor = new Mock<IHttpContextAccessor>();
|
|
var parameters = new List<VehicleFloorPricingParameters>
|
|
{
|
|
new VehicleFloorPricingParameters()
|
|
{
|
|
Id = 1,
|
|
LowCondition = 0.0m,
|
|
HighCondition = 1.5m,
|
|
NADAFirstValue = "Low Value",
|
|
NADASecondValue = "Low Value",
|
|
MMRAdjustedValue = "Regional Value",
|
|
PercentageOf = 95.00m
|
|
}
|
|
};
|
|
mockService.Setup(x => x.ListAll()).ReturnsAsync(parameters);
|
|
|
|
// arrange
|
|
var controller = new VehicleFloorPricingParametersController(mockService.Object,
|
|
mockHttpContextAccessor.Object);
|
|
|
|
// act
|
|
var result = await controller.Get();
|
|
Assert.NotNull(result);
|
|
var okResult = result as OkObjectResult;
|
|
|
|
// assert
|
|
Assert.NotNull(okResult);
|
|
Assert.Equal(200, okResult.StatusCode);
|
|
|
|
var okValue = okResult.Value as IEnumerable<VehicleFloorPricingParameters>;
|
|
Assert.NotNull(okValue);
|
|
Assert.True(parameters.SequenceEqual(okValue));
|
|
}
|
|
|
|
[Fact]
|
|
public async void GetById_OK()
|
|
{
|
|
var mockService = new Mock<IVehicleFloorPricingParametersService>();
|
|
var mockHttpContextAccessor = new Mock<IHttpContextAccessor>();
|
|
var repos = new List<VehicleFloorPricingParameters>
|
|
{
|
|
new VehicleFloorPricingParameters()
|
|
{
|
|
Id = 1,
|
|
LowCondition = 0.0m,
|
|
HighCondition = 1.5m,
|
|
NADAFirstValue = "Low Value",
|
|
NADASecondValue = "Low Value",
|
|
MMRAdjustedValue = "Regional Value",
|
|
PercentageOf = 95.00m
|
|
}
|
|
};
|
|
mockService.Setup(x => x.Get(It.IsAny<int>())).ReturnsAsync(repos.First());
|
|
|
|
// arrange
|
|
var controller = new VehicleFloorPricingParametersController(mockService.Object,
|
|
mockHttpContextAccessor.Object);
|
|
|
|
// act
|
|
var result = await controller.GetById(1234567);
|
|
Assert.NotNull(result);
|
|
var okResult = result as OkObjectResult;
|
|
|
|
// assert
|
|
Assert.NotNull(okResult);
|
|
Assert.Equal(200, okResult.StatusCode);
|
|
|
|
var okValue = okResult.Value as VehicleFloorPricingParameters;
|
|
Assert.NotNull(okValue);
|
|
Assert.Equal(1, okValue.Id);
|
|
}
|
|
}
|
|
} |