Exemplo n.º 1
0
        public async Task GivenDicomTagWithDifferentVR_WhenValidated_ThenShouldSkip()
        {
            var featureConfiguration = Options.Create(new FeatureConfiguration()
            {
                EnableFullDicomItemValidation = false
            });
            DicomTag     tag     = DicomTag.Date;
            DicomElement element = new DicomDateTime(tag, DateTime.Now);

            _dicomDataset.AddOrUpdate(element);

            _queryTags.Clear();
            _queryTags.Add(new QueryTag(tag.BuildExtendedQueryTagStoreEntry()));
            IDicomElementMinimumValidator validator = Substitute.For <IDicomElementMinimumValidator>();

            _dicomDatasetValidator = new DicomDatasetValidator(featureConfiguration, validator, _queryTagService);
            await _dicomDatasetValidator.ValidateAsync(_dicomDataset, requiredStudyInstanceUid : null);

            validator.DidNotReceive().Validate(Arg.Any <DicomElement>());
        }
        public async Task GivenDicomTagWithDifferentVR_WhenValidated_ThenShouldThrowException()
        {
            var featureConfiguration = Options.Create(new FeatureConfiguration()
            {
                EnableFullDicomItemValidation = false
            });
            DicomTag     tag     = DicomTag.Date;
            DicomElement element = new DicomDateTime(tag, DateTime.Now);

            _dicomDataset.AddOrUpdate(element);

            _queryTags.Clear();
            _queryTags.Add(new QueryTag(tag.BuildExtendedQueryTagStoreEntry()));
            IDicomElementMinimumValidator validator = Substitute.For <IDicomElementMinimumValidator>();

            _dicomDatasetValidator = new DicomDatasetValidator(featureConfiguration, validator, _queryTagService);
            await AssertThrowsAsyncWithMessage <DatasetValidationException>(
                () => _dicomDatasetValidator.ValidateAsync(_dicomDataset, requiredStudyInstanceUid: null),
                expectedMessage : $"The extended query tag '{tag}' is expected to have VR 'DA' but has 'DT' in file.");

            validator.DidNotReceive().Validate(Arg.Any <DicomElement>());
        }