Exemplo n.º 1
0
        public BundleHandlerTests()
        {
            _router = Substitute.For <IRouter>();

            var fhirRequestContext = new DefaultFhirRequestContext
            {
                BaseUri       = new Uri("https://localhost/"),
                CorrelationId = Guid.NewGuid().ToString(),
            };

            _fhirRequestContextAccessor = Substitute.For <IFhirRequestContextAccessor>();
            _fhirRequestContextAccessor.FhirRequestContext.Returns(fhirRequestContext);

            _httpContextAccessor = Substitute.For <IHttpContextAccessor>();

            _fhirJsonSerializer = new FhirJsonSerializer();
            _fhirJsonParser     = new FhirJsonParser();

            _searchService = Substitute.For <ISearchService>();

            var fhirDataStore              = Substitute.For <IFhirDataStore>();
            var conformanceProvider        = Substitute.For <Lazy <IConformanceProvider> >();
            var resourceWrapperFactory     = Substitute.For <IResourceWrapperFactory>();
            var resourceIdProvider         = Substitute.For <ResourceIdProvider>();
            var transactionBundleValidator = new TransactionBundleValidator(fhirDataStore, conformanceProvider, resourceWrapperFactory, _searchService, resourceIdProvider);

            _bundleHttpContextAccessor = new BundleHttpContextAccessor();

            IFeatureCollection featureCollection = CreateFeatureCollection();
            var httpContext = new DefaultHttpContext(featureCollection)
            {
                Request =
                {
                    Scheme   = "https",
                    Host     = new HostString("localhost"),
                    PathBase = new PathString("/"),
                },
            };

            _httpContextAccessor.HttpContext.Returns(httpContext);

            var transactionHandler = Substitute.For <ITransactionHandler>();

            _resourceIdProvider = new ResourceIdProvider();

            _auditEventTypeMapping = Substitute.For <IAuditEventTypeMapping>();

            _bundleHandler = new BundleHandler(
                _httpContextAccessor,
                _fhirRequestContextAccessor,
                _fhirJsonSerializer,
                _fhirJsonParser,
                transactionHandler,
                _bundleHttpContextAccessor,
                _resourceIdProvider,
                transactionBundleValidator,
                _auditEventTypeMapping,
                NullLogger <BundleHandler> .Instance);
        }
Exemplo n.º 2
0
        public TransactionBundleValidatorTests()
        {
            IFhirDataStore fhirDataStore = Substitute.For <IFhirDataStore>();
            Lazy <IConformanceProvider> conformanceProvider    = Substitute.For <Lazy <IConformanceProvider> >();
            IResourceWrapperFactory     resourceWrapperFactory = Substitute.For <IResourceWrapperFactory>();
            ResourceIdProvider          resourceIdProvider     = Substitute.For <ResourceIdProvider>();

            _transactionBundleValidator = new TransactionBundleValidator(fhirDataStore, conformanceProvider, resourceWrapperFactory, _searchService, resourceIdProvider);
        }
Exemplo n.º 3
0
        public BundleHandlerTests()
        {
            _router = Substitute.For <IRouter>();

            _fhirRequestContext = new DefaultFhirRequestContext
            {
                BaseUri         = new Uri("https://localhost/"),
                CorrelationId   = Guid.NewGuid().ToString(),
                ResponseHeaders = new HeaderDictionary(),
            };

            var fhirRequestContextAccessor = Substitute.For <RequestContextAccessor <IFhirRequestContext> >();

            fhirRequestContextAccessor.RequestContext.Returns(_fhirRequestContext);

            IHttpContextAccessor httpContextAccessor = Substitute.For <IHttpContextAccessor>();

            var fhirJsonSerializer = new FhirJsonSerializer();
            var fhirJsonParser     = new FhirJsonParser();

            ISearchService searchService              = Substitute.For <ISearchService>();
            var            resourceReferenceResolver  = new ResourceReferenceResolver(searchService, new QueryStringParser());
            var            transactionBundleValidator = new TransactionBundleValidator(resourceReferenceResolver);

            var bundleHttpContextAccessor = new BundleHttpContextAccessor();

            IFeatureCollection featureCollection = CreateFeatureCollection();
            var httpContext = new DefaultHttpContext(featureCollection)
            {
                Request =
                {
                    Scheme   = "https",
                    Host     = new HostString("localhost"),
                    PathBase = new PathString("/"),
                },
            };

            httpContextAccessor.HttpContext.Returns(httpContext);

            var transactionHandler = Substitute.For <ITransactionHandler>();

            var resourceIdProvider = new ResourceIdProvider();

            IAuditEventTypeMapping auditEventTypeMapping = Substitute.For <IAuditEventTypeMapping>();

            _bundleConfiguration = new BundleConfiguration();
            var bundleOptions = Substitute.For <IOptions <BundleConfiguration> >();

            bundleOptions.Value.Returns(_bundleConfiguration);

            _mediator = Substitute.For <IMediator>();

            _bundleHandler = new BundleHandler(
                httpContextAccessor,
                fhirRequestContextAccessor,
                fhirJsonSerializer,
                fhirJsonParser,
                transactionHandler,
                bundleHttpContextAccessor,
                resourceIdProvider,
                transactionBundleValidator,
                resourceReferenceResolver,
                auditEventTypeMapping,
                bundleOptions,
                DisabledFhirAuthorizationService.Instance,
                _mediator,
                NullLogger <BundleHandler> .Instance);
        }
 public TransactionBundleValidatorTests()
 {
     _transactionBundleValidator = new TransactionBundleValidator(new ResourceReferenceResolver(_searchService, new QueryStringParser()));
 }