Доработка базового класса парсера, тест метода расширения GetCellValue

This commit is contained in:
Степанов Дмитрий 2024-02-09 09:26:50 +03:00
parent bb5a02d8b1
commit aff243626a
2 changed files with 19 additions and 0 deletions

View File

@ -35,6 +35,14 @@ public abstract class ParserServiceBase<TDto, TOptions> : IParserService<TDto, T
{
var validationContext = new ValidationContext(dto, serviceProvider: null, items: null);
if (dto is IValidatableObject dtoWithValidateMethod)
{
var validationResults = dtoWithValidateMethod.Validate(validationContext);
foreach (var validationResult in validationResults)
ValidationResults.Add(validationResult);
}
if (Validator.TryValidateObject(dto, validationContext, ValidationResults, true))
{
var validRow = new ValidationResultDto<TDto>

View File

@ -1,4 +1,5 @@
using System;
using System.IO;
using AsbCloudInfrastructure;
using ClosedXML.Excel;
using Xunit;
@ -112,6 +113,16 @@ public class XLExtensionsTests
Assert.Equal(DateTimeKind.Unspecified, actualValue.Kind);
}
[Fact]
public void GetCellValue_returns_exception()
{
//arrange
SetCellValue("test");
//assert
Assert.Throws<FileFormatException>(() => GetCell(cellUsed).GetCellValue<double>());
}
[Fact]
public void GetCellValue_returns_nullable()
{