forked from ddrilling/AsbCloudServer
Доработка базового класса парсера, тест метода расширения GetCellValue
This commit is contained in:
parent
bb5a02d8b1
commit
aff243626a
@ -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>
|
||||
|
@ -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()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user