예제 #1
0
        public void GivenSearchIndicesWithResourceTypeAndCompartmentType_WhenExtracted_ThenCorrectIndicesExtracted(ResourceType resourceType, CompartmentType compartmentType, ReferenceKind referenceKind, string expectedResourceId)
        {
            HashSet <string> compParams = null;

            _compartmentManager.TryGetSearchParams(resourceType.ToString(), compartmentType, out compParams)
            .Returns(x =>
            {
                x[2] = new HashSet <string> {
                    _referenceSearchTestParam.Name, _nonReferenceReferenceSearchTestParam.Name
                };
                return(true);
            });
            var searchIndexEntries = new List <SearchIndexEntry>
            {
                new SearchIndexEntry(_referenceSearchTestParam, new ReferenceSearchValue(referenceKind, _baseUri, CompartmentDefinitionManager.CompartmentTypeToResourceType(compartmentType.ToString()).ToString(), expectedResourceId)),
                new SearchIndexEntry(_nonReferenceReferenceSearchTestParam, new StringSearchValue("aadsdas")),
            };
            CompartmentIndices compartmentIndices = _compartmentIndexer.Extract(resourceType.ToString(), searchIndexEntries);

            Assert.Collection(GetResourceIdsForCompartmentType(compartmentType, compartmentIndices), r => string.Equals(expectedResourceId, r, StringComparison.OrdinalIgnoreCase));
        }
예제 #2
0
        public void GivenSearchIndicesWithMultipleReferenceSearchParams_WhenExtracted_ThenCorrectIndicesExtracted(CompartmentType expectedCompartmentType1, CompartmentType expectedCompartmentType2, CompartmentType expectedCompartmentType3)
        {
            HashSet <string> compParams = null;
            string           expectedCareTeamResource = ResourceType.CareTeam.ToString();

            // Setup the compartment search definitions.
            _compartmentManager.TryGetSearchParams(expectedCareTeamResource, expectedCompartmentType1, out compParams)
            .Returns(x =>
            {
                x[2] = new HashSet <string> {
                    _referenceSearchTestParam.Name
                };
                return(true);
            });
            _compartmentManager.TryGetSearchParams(expectedCareTeamResource, expectedCompartmentType2, out compParams)
            .Returns(x =>
            {
                x[2] = new HashSet <string> {
                    _anotherReferenceSearchTestParam.Name
                };
                return(true);
            });
            _compartmentManager.TryGetSearchParams(expectedCareTeamResource, expectedCompartmentType3, out compParams)
            .Returns(x =>
            {
                x[2] = new HashSet <string> {
                    _yetAnotherReferenceSearchTestParam.Name
                };
                return(true);
            });
            const string ExpectedResourceIdR1 = "r1";
            const string ExpectedResourceIdR2 = "r2";
            const string ExpectedResourceIdR3 = "r3";

            // Setup multiple reference search parameters with expected resource ids for the compartments.
            var searchIndexEntries = new List <SearchIndexEntry>
            {
                new SearchIndexEntry(_referenceSearchTestParam, new ReferenceSearchValue(ReferenceKind.InternalOrExternal, _baseUri, CompartmentDefinitionManager.CompartmentTypeToResourceType(expectedCompartmentType1.ToString()).ToString(), ExpectedResourceIdR1)),
                new SearchIndexEntry(_anotherReferenceSearchTestParam, new ReferenceSearchValue(ReferenceKind.Internal, _baseUri, CompartmentDefinitionManager.CompartmentTypeToResourceType(expectedCompartmentType2.ToString()).ToString(), ExpectedResourceIdR2)),
                new SearchIndexEntry(_yetAnotherReferenceSearchTestParam, new ReferenceSearchValue(ReferenceKind.External, _baseUri, CompartmentDefinitionManager.CompartmentTypeToResourceType(expectedCompartmentType3.ToString()).ToString(), ExpectedResourceIdR3)),
            };

            CompartmentIndices compartmentIndices = _compartmentIndexer.Extract(expectedCareTeamResource, searchIndexEntries);

            Assert.Collection(GetResourceIdsForCompartmentType(expectedCompartmentType1, compartmentIndices), r => string.Equals(ExpectedResourceIdR1, r, StringComparison.OrdinalIgnoreCase));
            Assert.Collection(GetResourceIdsForCompartmentType(expectedCompartmentType2, compartmentIndices), r => string.Equals(ExpectedResourceIdR2, r, StringComparison.OrdinalIgnoreCase));
            Assert.Collection(GetResourceIdsForCompartmentType(expectedCompartmentType3, compartmentIndices), r => string.Equals(ExpectedResourceIdR3, r, StringComparison.OrdinalIgnoreCase));
        }