public void GivenMultipleStringSearchValueForOneParameter_WhenCreate_ThenMinMaxValuesSetCorrectly()
        {
            var searchIndexEntry1 = new SearchIndexEntry(_nameSearchParameterInfo, new StringSearchValue("alpha"));
            var searchIndexEntry2 = new SearchIndexEntry(_nameSearchParameterInfo, new StringSearchValue("beta"));
            var searchIndexEntry3 = new SearchIndexEntry(_nameSearchParameterInfo, new StringSearchValue("gamma"));

            _searchIndexer
            .Extract(Arg.Any <ResourceElement>())
            .Returns(new List <SearchIndexEntry>()
            {
                searchIndexEntry1, searchIndexEntry2, searchIndexEntry3
            });

            ResourceElement resource        = Samples.GetDefaultPatient(); // Resource does not matter for this test.
            ResourceWrapper resourceWrapper = _resourceWrapperFactory.Create(resource, deleted: false, keepMeta: false);

            foreach (SearchIndexEntry searchEntry in resourceWrapper.SearchIndices)
            {
                ISupportSortSearchValue searchEntryValue = searchEntry.Value as ISupportSortSearchValue;
                switch (searchEntry.Value.ToString())
                {
                case "alpha":
                    Assert.True(searchEntryValue.IsMin);
                    Assert.False(searchEntryValue.IsMax);
                    break;

                case "beta":
                    Assert.False(searchEntryValue.IsMin);
                    Assert.False(searchEntryValue.IsMax);
                    break;

                case "gamma":
                    Assert.False(searchEntryValue.IsMin);
                    Assert.True(searchEntryValue.IsMax);
                    break;

                default:
                    throw new Exception("Unexpected value");
                }
            }
        }
Ejemplo n.º 2
0
        private (Hl7.Fhir.Model.Bundle rawBundle, Hl7.Fhir.Model.Bundle bundle) CreateBundle(params ResourceElement[] resources)
        {
            string id        = Guid.NewGuid().ToString();
            var    rawBundle = new Hl7.Fhir.Model.Bundle();
            var    bundle    = new Hl7.Fhir.Model.Bundle();

            rawBundle.Id    = bundle.Id = id;
            rawBundle.Type  = bundle.Type = BundleType.Searchset;
            rawBundle.Entry = new List <EntryComponent>();
            rawBundle.Total = resources.Count();
            bundle.Entry    = new List <EntryComponent>();
            bundle.Total    = resources.Count();

            foreach (var resource in resources)
            {
                var poco = resource.ToPoco();
                poco.VersionId        = "1";
                poco.Meta.LastUpdated = Clock.UtcNow;
                poco.Meta.Tag         = new List <Hl7.Fhir.Model.Coding>
                {
                    new Hl7.Fhir.Model.Coding {
                        System = "testTag", Code = Guid.NewGuid().ToString()
                    },
                };
                var wrapper = _wrapperFactory.Create(poco.ToResourceElement(), deleted: false, keepMeta: true);
                wrapper.Version = "1";

                var requestComponent = new RequestComponent {
                    Method = HTTPVerb.POST, Url = "patient/"
                };
                var responseComponent = new ResponseComponent {
                    Etag = "W/\"1\"", LastModified = DateTimeOffset.UtcNow, Status = "201 Created"
                };
                rawBundle.Entry.Add(new RawBundleEntryComponent(wrapper)
                {
                    Request  = requestComponent,
                    Response = responseComponent,
                });
                bundle.Entry.Add(new EntryComponent {
                    Resource = poco, Request = requestComponent, Response = responseComponent
                });
            }

            return(rawBundle, bundle);
        }