protected override void PopulateView()
 {
     foreach (var file in Resource.EnumerateFiles())
     {
         Nodes.Add(( TreeNode )ResourceWrapperFactory.GetResourceWrapper(file, Resource.OpenFile(file)));
     }
 }
Example #2
0
 protected override void PopulateView()
 {
     foreach (int file in Resource.EnumerateFiles())
     {
         Nodes.Add(( TreeNode )ResourceWrapperFactory.GetResourceWrapper($"Sound{file:D2}.adx", Resource.OpenFile(file)));
     }
 }
 protected override void PopulateView()
 {
     for (var i = 0; i < Resource.Entries.Count; i++)
     {
         Nodes.Add((TreeNode)ResourceWrapperFactory.GetResourceWrapper($"MessageScript{i:0000}", new MemoryStream(Resource.Entries[i].Data)));
     }
 }
        public async Task InitializeAsync()
        {
            _fhirOperationDataStore         = _fixture.OperationDataStore;
            _fhirStorageTestHelper          = _fixture.TestHelper;
            _scopedOperationDataStore       = _fixture.OperationDataStore.CreateMockScope();
            _scopedDataStore                = _fixture.DataStore.CreateMockScope();
            _searchParameterStatusDataStore = _fixture.SearchParameterStatusDataStore;

            _jobConfiguration = new ReindexJobConfiguration();
            IOptions <ReindexJobConfiguration> optionsReindexConfig = Substitute.For <IOptions <ReindexJobConfiguration> >();

            optionsReindexConfig.Value.Returns(_jobConfiguration);

            _searchParameterDefinitionManager = new SearchParameterDefinitionManager(ModelInfoProvider.Instance);
            await _searchParameterDefinitionManager.StartAsync(CancellationToken.None);

            _supportedSearchParameterDefinitionManager = new SupportedSearchParameterDefinitionManager(_searchParameterDefinitionManager);
            var fhirRequestContextAccessor = Substitute.For <IFhirRequestContextAccessor>();

            _searchableSearchParameterDefinitionManager = new SearchableSearchParameterDefinitionManager(_searchParameterDefinitionManager, fhirRequestContextAccessor);

            ResourceWrapperFactory wrapperFactory = Mock.TypeWithArguments <ResourceWrapperFactory>(
                new RawResourceFactory(new FhirJsonSerializer()),
                _searchIndexer,
                _searchableSearchParameterDefinitionManager,
                Deserializers.ResourceDeserializer);

            _searchParameterStatusManager = new SearchParameterStatusManager(
                _searchParameterStatusDataStore,
                _searchParameterDefinitionManager,
                _searchParameterSupportResolver,
                _mediator);

            _createReindexRequestHandler = new CreateReindexRequestHandler(
                _fhirOperationDataStore,
                DisabledFhirAuthorizationService.Instance,
                optionsReindexConfig,
                _searchParameterDefinitionManager);
            _reindexUtilities = new ReindexUtilities(
                () => _scopedDataStore,
                _searchIndexer,
                Deserializers.ResourceDeserializer,
                _supportedSearchParameterDefinitionManager,
                _searchParameterStatusManager,
                wrapperFactory);

            coreOptions.Value.Returns(new CoreFeatureConfiguration());

            var searchParameterExpressionParser = new SearchParameterExpressionParser(new ReferenceSearchValueParser(fhirRequestContextAccessor));
            var expressionParser     = new ExpressionParser(() => _searchableSearchParameterDefinitionManager, searchParameterExpressionParser);
            var searchOptionsFactory = new SearchOptionsFactory(expressionParser, () => _searchableSearchParameterDefinitionManager, coreOptions, fhirRequestContextAccessor, _sortingValidator, NullLogger <SearchOptionsFactory> .Instance);
            var cosmosSearchService  = new FhirCosmosSearchService(searchOptionsFactory, _fixture.DataStore as CosmosFhirDataStore, new QueryBuilder(), _searchParameterDefinitionManager, fhirRequestContextAccessor) as ISearchService;

            _searchService = cosmosSearchService.CreateMockScope();

            await _fhirStorageTestHelper.DeleteAllReindexJobRecordsAsync(CancellationToken.None);
        }
Example #5
0
        protected override void PopulateView()
        {
            if (mElementNameProvider != null)
            {
                for (var i = 0; i < Resource.Count; i++)
                {
                    var    res  = Resource[i];
                    string name = mElementNameProvider.Invoke(res, i);

                    Nodes.Add((TreeNode)ResourceWrapperFactory.GetResourceWrapper(name, res));
                }
            }
        }
        public BundleSerializerTests()
        {
            var requestContextAccessor = Substitute.For <IFhirRequestContextAccessor>();

            requestContextAccessor.FhirRequestContext.Returns(x => new FhirRequestContext("get", "https://localhost/Patient", "https://localhost", "correlation", new Dictionary <string, StringValues>(), new Dictionary <string, StringValues>()));

            _wrapperFactory = new ResourceWrapperFactory(
                new RawResourceFactory(new FhirJsonSerializer()),
                requestContextAccessor,
                Substitute.For <ISearchIndexer>(),
                Substitute.For <IClaimsExtractor>(),
                Substitute.For <ICompartmentIndexer>());
        }
Example #7
0
        public async Task InitializeAsync()
        {
            _fhirOperationDataStore   = _fixture.OperationDataStore;
            _fhirStorageTestHelper    = _fixture.TestHelper;
            _scopedOperationDataStore = _fhirOperationDataStore.CreateMockScope();
            _scopedDataStore          = _fixture.DataStore.CreateMockScope();

            _jobConfiguration = new ReindexJobConfiguration();
            IOptions <ReindexJobConfiguration> optionsReindexConfig = Substitute.For <IOptions <ReindexJobConfiguration> >();

            optionsReindexConfig.Value.Returns(_jobConfiguration);

            _searchParameterDefinitionManager          = _fixture.SearchParameterDefinitionManager;
            _supportedSearchParameterDefinitionManager = _fixture.SupportedSearchParameterDefinitionManager;

            ResourceWrapperFactory wrapperFactory = Mock.TypeWithArguments <ResourceWrapperFactory>(
                new RawResourceFactory(new FhirJsonSerializer()),
                new FhirRequestContextAccessor(),
                _searchIndexer,
                _searchParameterDefinitionManager,
                Deserializers.ResourceDeserializer);

            _searchParameterStatusManager = _fixture.SearchParameterStatusManager;

            _createReindexRequestHandler = new CreateReindexRequestHandler(
                _fhirOperationDataStore,
                DisabledFhirAuthorizationService.Instance,
                optionsReindexConfig,
                _searchParameterDefinitionManager,
                _searchParameterOperations);

            _reindexUtilities = new ReindexUtilities(
                () => _scopedDataStore,
                _searchIndexer,
                Deserializers.ResourceDeserializer,
                _supportedSearchParameterDefinitionManager,
                _searchParameterStatusManager,
                wrapperFactory);

            _searchService = _fixture.SearchService.CreateMockScope();

            await _fhirStorageTestHelper.DeleteAllReindexJobRecordsAsync(CancellationToken.None);

            _throttleController.GetThrottleBasedDelay().Returns(0);
            _throttleController.GetThrottleBatchSize().Returns(100U);
        }
        public ResourceWrapperFactoryTests()
        {
            var serializer = new FhirJsonSerializer();

            _rawResourceFactory = new RawResourceFactory(serializer);

            var dummyRequestContext = new FhirRequestContext(
                "POST",
                "https://localhost/Patient",
                "https://localhost/",
                Guid.NewGuid().ToString(),
                new Dictionary <string, StringValues>(),
                new Dictionary <string, StringValues>());

            _fhirRequestContextAccessor = Substitute.For <RequestContextAccessor <IFhirRequestContext> >();
            _fhirRequestContextAccessor.RequestContext.Returns(dummyRequestContext);

            _claimsExtractor    = Substitute.For <IClaimsExtractor>();
            _compartmentIndexer = Substitute.For <ICompartmentIndexer>();
            _searchIndexer      = Substitute.For <ISearchIndexer>();

            _searchParameterDefinitionManager = Substitute.For <ISearchParameterDefinitionManager>();
            _searchParameterDefinitionManager.GetSearchParameterHashForResourceType(Arg.Any <string>()).Returns("hash");

            _resourceWrapperFactory = new ResourceWrapperFactory(
                _rawResourceFactory,
                _fhirRequestContextAccessor,
                _searchIndexer,
                _claimsExtractor,
                _compartmentIndexer,
                _searchParameterDefinitionManager,
                Deserializers.ResourceDeserializer);

            _nameSearchParameterInfo = new SearchParameterInfo("name", "name", ValueSets.SearchParamType.String, new Uri("https://localhost/searchParameter/name"))
            {
                SortStatus = SortParameterStatus.Enabled
            };
            _addressSearchParameterInfo = new SearchParameterInfo("address-city", "address-city", ValueSets.SearchParamType.String, new Uri("https://localhost/searchParameter/address-city"))
            {
                SortStatus = SortParameterStatus.Enabled
            };
            _ageSearchParameterInfo = new SearchParameterInfo("age", "age", ValueSets.SearchParamType.Number, new Uri("https://localhost/searchParameter/age"))
            {
                SortStatus = SortParameterStatus.Supported
            };
        }
Example #9
0
        protected override void Initialize()
        {
            CommonContextMenuOptions = CommonContextMenuOptions.Export | CommonContextMenuOptions.Replace | CommonContextMenuOptions.Add |
                                       CommonContextMenuOptions.Move | CommonContextMenuOptions.Rename | CommonContextMenuOptions.Delete;

            RegisterFileExportAction(SupportedFileType.RwTextureDictionaryNode, (res, path) => res.Save(path));
            RegisterCustomAction("Export All", Keys.None, (o, s) =>
            {
                using (FolderBrowserDialog dialog = new FolderBrowserDialog())
                {
                    dialog.ShowNewFolderButton = true;

                    if (dialog.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }

                    foreach (var texture in Resource.Textures)
                    {
                        var path   = Path.Combine(dialog.SelectedPath, Path.ChangeExtension(texture.Name, "png"));
                        var bitmap = texture.GetBitmap();

                        bitmap.Save(path);
                    }
                }
            });
            RegisterFileReplaceAction(SupportedFileType.RwTextureDictionaryNode, (res, path) => (RwTextureDictionaryNode)RwNode.Load(path));
            RegisterFileAddAction(SupportedFileType.RwTextureNativeNode, DefaultFileAddAction);
            RegisterFileAddAction(SupportedFileType.Bitmap, (path, wrap) =>
            {
                var resWrap = (BitmapWrapper)ResourceWrapperFactory.GetResourceWrapper(path);
                var name    = Path.GetFileNameWithoutExtension(path);
                wrap.Nodes.Add(new RwTextureNativeNodeWrapper(new RwTextureNativeNode(name, resWrap.Resource)));
            });
            RegisterRebuildAction(wrap =>
            {
                var textureDictionary = new RwTextureDictionaryNode();

                foreach (RwTextureNativeNodeWrapper textureNodeWrapper in Nodes)
                {
                    textureDictionary.Textures.Add(textureNodeWrapper.Resource);
                }

                return(textureDictionary);
            });
        }