コード例 #1
0
        public void GivenAValidSearchParameterDefinitionFile_WhenBuilt_ThenUriDictionaryShouldContainAllSearchParameters()
        {
            _builderWithValidEntries.Build();

            Assert.Equal(6, _builderWithValidEntries.UriDictionary.Count);

            Bundle bundle = Definitions.GetDefinition("SearchParameters");

            Assert.Equal(
                bundle.Entry.Select(entry => entry.FullUrl),
                _builderWithValidEntries.UriDictionary.Values.Select(value => value.Url.ToString()));
        }
コード例 #2
0
        public void GivenAValidSearchParameterDefinitionFile_WhenBuilt_ThenAllResourceTypesShouldBeIncluded()
        {
            var bundle = SearchParameterDefinitionBuilder.ReadEmbeddedSearchParameters(
                _validEntriesFile,
                ModelInfoProvider.Instance,
                $"{typeof(Definitions).Namespace}.DefinitionFiles",
                typeof(EmbeddedResourceManager).Assembly);

            SearchParameterDefinitionBuilder.Build(bundle.Entries.Select(e => e.Resource).ToList(), _uriDictionary, _resourceTypeDictionary, ModelInfoProvider.Instance);

            Assert.Equal(
                ModelInfoProvider.GetResourceTypeNames().Concat(new[] { "Resource", "DomainResource" }).OrderBy(x => x).ToArray(),
                _resourceTypeDictionary.Select(x => x.Key).OrderBy(x => x).ToArray());
        }
コード例 #3
0
        private void BuildAndVerify(string filename, string expectedIssue)
        {
            var bundle = SearchParameterDefinitionBuilder.ReadEmbeddedSearchParameters(
                filename,
                ModelInfoProvider.Instance,
                $"{typeof(Definitions).Namespace}.DefinitionFiles",
                typeof(EmbeddedResourceManager).Assembly);

            InvalidDefinitionException ex = Assert.Throws <InvalidDefinitionException>(
                () => SearchParameterDefinitionBuilder.Build(bundle.Entries.Select(e => e.Resource).ToList(), _uriDictionary, _resourceTypeDictionary, ModelInfoProvider.Instance));

            Assert.Contains(ex.Issues, issue =>
                            issue.Severity == IssueSeverity.Fatal.ToString() &&
                            issue.Code == IssueType.Invalid.ToString() &&
                            issue.Diagnostics.StartsWith(expectedIssue));
        }
コード例 #4
0
        public void GivenAValidSearchParameterDefinitionFile_WhenBuilt_ThenUriDictionaryShouldContainAllSearchParameters()
        {
            var bundle = SearchParameterDefinitionBuilder.ReadEmbeddedSearchParameters(
                _validEntriesFile,
                ModelInfoProvider.Instance,
                $"{typeof(Definitions).Namespace}.DefinitionFiles",
                typeof(EmbeddedResourceManager).Assembly);

            SearchParameterDefinitionBuilder.Build(bundle.Entries.Select(e => e.Resource).ToList(), _uriDictionary, _resourceTypeDictionary, ModelInfoProvider.Instance);

            Assert.Equal(6, _uriDictionary.Count);

            Bundle staticBundle = Definitions.GetDefinition("SearchParameters");

            Assert.Equal(
                staticBundle.Entry.Select(entry => entry.FullUrl).OrderBy(s => s, StringComparer.OrdinalIgnoreCase),
                _uriDictionary.Values.Select(value => value.Url.ToString()).OrderBy(s => s, StringComparer.OrdinalIgnoreCase));
        }
コード例 #5
0
        public void GivenAValidSearchParameterDefinitionFile_WhenBuilt_ThenCorrectListOfSearchParametersIsBuiltForEntriesWithMultipleBase(ResourceType resourceType)
        {
            var bundle = SearchParameterDefinitionBuilder.ReadEmbeddedSearchParameters(
                _validEntriesFile,
                ModelInfoProvider.Instance,
                $"{typeof(Definitions).Namespace}.DefinitionFiles",
                typeof(EmbeddedResourceManager).Assembly);

            SearchParameterDefinitionBuilder.Build(bundle.Entries.Select(e => e.Resource).ToList(), _uriDictionary, _resourceTypeDictionary, ModelInfoProvider.Instance);

            IDictionary <string, SearchParameterInfo> searchParametersDictionary = _resourceTypeDictionary[resourceType.ToString()];

            ValidateSearchParameters(
                searchParametersDictionary,
                ("_type", SearchParamType.Token, "Resource.type().name"),
                ("_id", SearchParamType.Token, "Resource.id"),
                ("identifier", SearchParamType.Token, "MedicationRequest.identifier | MedicationAdministration.identifier | Medication.identifier | MedicationDispense.identifier"));
        }
コード例 #6
0
        private void BuildAndVerify(SearchParameterDefinitionBuilder builder, string expectedIssue)
        {
            InvalidDefinitionException ex = Assert.Throws <InvalidDefinitionException>(() => builder.Build());

            Assert.Contains(ex.Issues, issue =>
                            issue.Severity == IssueSeverity.Fatal.ToString() &&
                            issue.Code == IssueType.Invalid.ToString() &&
                            issue.Diagnostics.StartsWith(expectedIssue));
        }