public async Task ValidateDataFilesForUpload_MetadataFileNotCsv() { var(subjectService, fileTypeService) = Mocks(); await using (var context = InMemoryApplicationDbContext()) { var service = new FileUploadsValidatorService(subjectService.Object, fileTypeService.Object, context); var dataFile = CreateSingleLineFormFile("test.csv", "test.csv"); var metaFile = CreateSingleLineFormFile("test.meta.csv", "test.meta.csv"); fileTypeService .Setup(s => s.HasMatchingMimeType(dataFile, It.IsAny <IEnumerable <Regex> >())) .ReturnsAsync(() => true); fileTypeService .Setup(s => s.HasMatchingMimeType(metaFile, It.IsAny <IEnumerable <Regex> >())) .ReturnsAsync(() => false); fileTypeService .Setup(s => s.HasMatchingEncodingType(dataFile, It.IsAny <IEnumerable <string> >())) .Returns(() => true); fileTypeService .Setup(s => s.HasMatchingEncodingType(metaFile, It.IsAny <IEnumerable <string> >())) .Returns(() => true); var result = await service.ValidateDataFilesForUpload(Guid.NewGuid(), dataFile, metaFile); Assert.True(result.IsLeft); AssertValidationProblem(result.Left, MetaFileMustBeCsvFile); } }
public async Task ValidateDataFilesForUpload_MetadataFileIsEmpty() { var(subjectService, fileTypeService) = Mocks(); await using (var context = InMemoryApplicationDbContext()) { var service = new FileUploadsValidatorService(subjectService.Object, fileTypeService.Object, context); var dataFile = CreateSingleLineFormFile("test.csv", "test.csv"); var metaFile = CreateFormFile("test.meta.csv", "test.meta.csv"); var result = await service.ValidateDataFilesForUpload(Guid.NewGuid(), dataFile, metaFile); Assert.True(result.IsLeft); AssertValidationProblem(result.Left, MetadataFileCannotBeEmpty); } }