Exemple #1
1
        public void TestInitialize()
        {

            IFhirModel _fhirModel;
            FhirPropertyIndex _propIndex;
            ResourceVisitor _resourceVisitor;
            ElementIndexer _elementIndexer;
            var _indexStoreMock = new Mock<IIndexStore>();

            var spPatientName = new SearchParamDefinition() { Resource = "Patient", Name = "name", Description = @"A portion of either family or given name of the patient", Type = SearchParamType.String, Path = new string[] { "Patient.name", } };
            var searchParameters = new List<SearchParamDefinition> { spPatientName };
            var resources = new Dictionary<Type, string> { { typeof(Patient), "Patient" }, { typeof(HumanName), "HumanName" } };
            var enums = new List<Type>();
            //CK: I use real objects: saves me a lot of mocking and provides for a bit of integration testing.
            _fhirModel = new FhirModel(resources, searchParameters, enums);
            _propIndex = new FhirPropertyIndex(_fhirModel, new List<Type> { typeof(Patient), typeof(HumanName) });
            _resourceVisitor = new ResourceVisitor(_propIndex);
            _elementIndexer = new ElementIndexer(_fhirModel);

            //_indexStoreMock.Setup(ixs => ixs.Save(It.IsAny<IndexValue>))

            sutLimited = new IndexService(_fhirModel, _propIndex, _resourceVisitor, _elementIndexer, _indexStoreMock.Object);

            _fhirModel = new FhirModel(); //For this test I want all available types and searchparameters.
            _propIndex = new FhirPropertyIndex(_fhirModel);
            _resourceVisitor = new ResourceVisitor(_propIndex);
            _elementIndexer = new ElementIndexer(_fhirModel);

            sutFull = new IndexService(_fhirModel, _propIndex, _resourceVisitor, _elementIndexer, _indexStoreMock.Object);
        }
Exemple #2
0
 public IndexService(IFhirModel fhirModel, ResourceVisitor resourceVisitor, ElementIndexer elementIndexer, IIndexStore indexStore)
 {
     _fhirModel       = fhirModel;
     _resourceVisitor = resourceVisitor;
     _elementIndexer  = elementIndexer;
     _indexStore      = indexStore;
 }
Exemple #3
0
 public IndexService(IFhirModel fhirModel, FhirPropertyIndex propIndex, ResourceVisitor resourceVisitor, ElementIndexer elementIndexer, IIndexStore indexStore)
 {
     _fhirModel       = fhirModel;
     _propIndex       = propIndex;
     _resourceVisitor = resourceVisitor;
     _elementIndexer  = elementIndexer;
     _indexStore      = indexStore;
 }
Exemple #4
0
 public IndexService(IFhirModel fhirModel, FhirPropertyIndex propIndex, ResourceVisitor resourceVisitor, ElementIndexer elementIndexer, IIndexStore indexStore)
 {
     _fhirModel = fhirModel;
     _propIndex = propIndex;
     _resourceVisitor = resourceVisitor;
     _elementIndexer = elementIndexer;
     _indexStore = indexStore;
 }
Exemple #5
0
        //private ObservableEventListener eventListener;
        //private EventEntry lastLogEntry;

        //private class LogObserver : IObserver<EventEntry>
        //{
        //    private readonly Action<EventEntry> _resultAction;
        //    public LogObserver(Action<EventEntry> resultAction)
        //    {
        //        _resultAction = resultAction;
        //    }
        //    public void OnCompleted()
        //    {
        //    }

        //    public void OnError(Exception error)
        //    {
        //    }

        //    public void OnNext(EventEntry value)
        //    {
        //        _resultAction(value);
        //    }
        //}

        public ElementIndexerTests()
        {
            var fhirModel = new FhirModel();

            //eventListener = new ObservableEventListener();
            //eventListener.EnableEvents(SparkEngineEventSource.Log, EventLevel.LogAlways,
            //      Keywords.All);
            //eventListener.Subscribe(new LogObserver(result => lastLogEntry = result));
            _sut = new ElementIndexer(fhirModel, new Mock <ILogger <ElementIndexer> >().Object);
        }
        public void InitializeTest()
        {
            var fhirModel = new FhirModel();

            eventListener = new ObservableEventListener();
            eventListener.EnableEvents(SparkEngineEventSource.Log, EventLevel.LogAlways,
                                       Keywords.All);
            eventListener.Subscribe(new LogObserver(result => lastLogEntry = result));
            sut = new ElementIndexer(fhirModel);
        }
        public int IndexOf(ArticleElement @object)
        {
            if (@object == null)
            {
                return(-1); // NOTE: By definition, no bead can be null.
            }
            ElementIndexer indexer = new ElementIndexer(@object.BaseDataObject);

            Iterate(indexer);
            return(indexer.Index);
        }
Exemple #8
0
        public IndexServiceTests()
        {
            var indexStoreMock = new Mock <IIndexStore>();

            _examplePatientJson = TextFileHelper.ReadTextFileFromDisk(
                $".{Path.DirectorySeparatorChar}Examples{Path.DirectorySeparatorChar}patient-example.json");
            _exampleAppointmentJson = TextFileHelper.ReadTextFileFromDisk(
                $".{Path.DirectorySeparatorChar}Examples{Path.DirectorySeparatorChar}appointment-example2doctors.json");
            _carePlanWithContainedGoal = TextFileHelper.ReadTextFileFromDisk(
                $".{Path.DirectorySeparatorChar}Examples{Path.DirectorySeparatorChar}careplan-example-f201-renal.json");
            _exampleObservationJson = TextFileHelper.ReadTextFileFromDisk(
                $".{Path.DirectorySeparatorChar}Examples{Path.DirectorySeparatorChar}observation-example-bloodpressure.json");
            var spPatientName = new SearchParamDefinition
            {
                Resource    = "Patient",
                Name        = "name",
                Description = new Markdown(@"A portion of either family or given name of the patient"),
                Type        = SearchParamType.String,
                Path        = new[] { "Patient.name" },
                Expression  = "Patient.name"
            };
            var spMiddleName = new SearchParamDefinition
            {
                Resource = "Patient",
                Name     = "middlename",
                Type     = SearchParamType.String,
                Path     = new[]
                {
                    "Patient.name.extension.where(url='http://hl7.no/fhir/StructureDefinition/no-basis-middlename')"
                },
                Expression =
                    "Patient.name.extension.where(url='http://hl7.no/fhir/StructureDefinition/no-basis-middlename')"
            };
            var searchParameters = new List <SearchParamDefinition> {
                spPatientName, spMiddleName
            };
            var resources =
                new Dictionary <Type, string> {
                { typeof(Patient), "Patient" }, { typeof(HumanName), "HumanName" }
            };

            // For this test setup we want a limited available types and search parameters.
            IFhirModel limitedFhirModel      = new FhirModel(resources, searchParameters);
            var        limitedElementIndexer = new ElementIndexer(limitedFhirModel, new Mock <ILogger <ElementIndexer> >().Object);

            _limitedIndexService = new IndexService(limitedFhirModel, indexStoreMock.Object, limitedElementIndexer);

            // For this test setup we want all available types and search parameters.
            IFhirModel fullFhirModel      = new FhirModel();
            var        fullElementIndexer = new ElementIndexer(fullFhirModel, new Mock <ILogger <ElementIndexer> >().Object);

            _fullIndexService = new IndexService(fullFhirModel, indexStoreMock.Object, fullElementIndexer);
        }
Exemple #9
0
    /// <summary>
    /// Validates the elements and returns the height of all elements.
    /// </summary>
    /// <param name="rowElements">The row elements.</param>
    /// <returns></returns>
    private int ValidateElements(ElementIndexer[] rowElements) {
        int height = Constants.Zero;
        var indexesFound = new List<int>(rowElements.Length);
        rowElements.ForAll(e => {

            int index = e.index;
            D.AssertNotEqual(Constants.MinusOne, index, e.gameObject.name);
            if (indexesFound.Contains(index)) {
                D.Warn("Duplicate {0} index {1} found. Order will not be deterministic.", typeof(ElementIndexer).Name, index);
            }
            indexesFound.Add(index);

            if (height == Constants.Zero) {
                height = e.GetComponent<UIWidget>().height;
            }
            else {
                D.AssertEqual(height, e.gameObject.GetComponent<UIWidget>().height);
            }
        });
        return height;
    }
Exemple #10
0
        public void TestInitialize()
        {
            IFhirModel        _fhirModel;
            FhirPropertyIndex _propIndex;
            ResourceVisitor   _resourceVisitor;
            ElementIndexer    _elementIndexer;
            var _indexStoreMock = new Mock <IIndexStore>();

            var spPatientName = new SearchParamDefinition()
            {
                Resource = "Patient", Name = "name", Description = @"A portion of either family or given name of the patient", Type = SearchParamType.String, Path = new string[] { "Patient.name", }
            };
            var searchParameters = new List <SearchParamDefinition> {
                spPatientName
            };
            var resources = new Dictionary <Type, string> {
                { typeof(Patient), "Patient" }, { typeof(HumanName), "HumanName" }
            };
            var enums = new List <Type>();

            //CK: I use real objects: saves me a lot of mocking and provides for a bit of integration testing.
            _fhirModel = new FhirModel(resources, searchParameters, enums);
            _propIndex = new FhirPropertyIndex(_fhirModel, new List <Type> {
                typeof(Patient), typeof(HumanName)
            });
            _resourceVisitor = new ResourceVisitor(_propIndex);
            _elementIndexer  = new ElementIndexer(_fhirModel);

            //_indexStoreMock.Setup(ixs => ixs.Save(It.IsAny<IndexValue>))

            sutLimited = new IndexService(_fhirModel, _propIndex, _resourceVisitor, _elementIndexer, _indexStoreMock.Object);

            _fhirModel       = new FhirModel(); //For this test I want all available types and searchparameters.
            _propIndex       = new FhirPropertyIndex(_fhirModel);
            _resourceVisitor = new ResourceVisitor(_propIndex);
            _elementIndexer  = new ElementIndexer(_fhirModel);

            sutFull = new IndexService(_fhirModel, _propIndex, _resourceVisitor, _elementIndexer, _indexStoreMock.Object);
        }
Exemple #11
0
 /// <summary>
 /// Positions the element and adds a separator to its right (if indicated).
 /// Returns the starting localPosition.x for the next element which will be to the immediate
 /// right of the end of the element and/or separator.
 /// </summary>
 /// <param name="element">The element.</param>
 /// <param name="localPositionX">The value to set the element's localPosition.x.</param>
 /// <param name="addSeparator">if set to <c>true</c> [add separator].</param>
 /// <returns></returns>
 private int PositionElement(ElementIndexer element, int localPositionX, bool addSeparator) {
     //D.Log("{0} setting {1} to localPosition.x = {2}.", GetType().Name, element.GetType().Name, localPositionX);
     element.transform.localPosition = new Vector3(localPositionX, _rowMemberLocalPositionY);
     element.transform.SetSiblingIndex(element.index);
     var elementWidth = element.GetComponent<UIWidget>().width;
     var nextLocalPositionX = localPositionX + elementWidth;
     if (addSeparator) {
         MakeAndPositionSeparator(nextLocalPositionX);
         nextLocalPositionX += _separatorWidth;
     }
     //D.Log("{0} local position now at {1}.", element.GetType().Name, element.transform.localPosition);
     return nextLocalPositionX;
 }
Exemple #12
0
 public void InitializeTest()
 {
     var fhirModel = new FhirModel();
     sut = new ElementIndexer(fhirModel);
 }
 /// <summary>
 /// Validates the elements.
 /// </summary>
 /// <param name="rowElements">The row elements.</param>
 /// <returns></returns>
 private void ValidateElements(ElementIndexer[] rowElements) {
     var indexesFound = new List<int>(rowElements.Length);
     rowElements.ForAll(e => {
         int index = e.index;
         D.AssertNotEqual(Constants.MinusOne, index, "{0}.{1} not set.".Inject(e.gameObject.name, typeof(ElementIndexer).Name));
         if (indexesFound.Contains(index)) {
             D.Warn("Duplicate {0} index {1} found. Order will not be deterministic.", typeof(ElementIndexer).Name, index);
         }
         indexesFound.Add(index);
     });
 }
        public void InitializeTest()
        {
            var fhirModel = new FhirModel();

            sut = new ElementIndexer(fhirModel);
        }
Exemple #15
0
 public IndexService(IFhirModel fhirModel, IIndexStore indexStore, ElementIndexer elementIndexer)
 {
     _fhirModel      = fhirModel;
     _indexStore     = indexStore;
     _elementIndexer = elementIndexer;
 }