Ejemplo n.º 1
0
        public FhirRequestContextRouteDataPopulatingFilterAttributeTests()
        {
            var controllerActionDescriptor = new ControllerActionDescriptor
            {
                DisplayName        = "Executing Context Test Descriptor",
                ActionName         = ActionName,
                ControllerName     = ControllerName,
                AttributeRouteInfo = new AttributeRouteInfo
                {
                    Name = RouteName,
                },
            };

            _actionExecutingContext = new ActionExecutingContext(
                new ActionContext(_httpContext, new RouteData(), controllerActionDescriptor),
                new List <IFilterMetadata>(),
                new Dictionary <string, object>(),
                FilterTestsHelper.CreateMockFhirController());

            _actionExecutedContext = new ActionExecutedContext(
                new ActionContext(_httpContext, new RouteData(), controllerActionDescriptor),
                new List <IFilterMetadata>(),
                FilterTestsHelper.CreateMockFhirController());

            _fhirRequestContext.CorrelationId = _correlationId;
            _fhirRequestContextAccessor.FhirRequestContext.Returns(_fhirRequestContext);

            _filterAttribute = new FhirRequestContextRouteDataPopulatingFilterAttribute(_fhirRequestContextAccessor, _auditEventTypeMapping);
        }
        private void ExecuteAndValidateFilter(string auditEventTypeFromMapping, string expectedAuditEventType)
        {
            _auditEventTypeMapping.GetAuditEventType(ControllerName, ActionName).Returns(auditEventTypeFromMapping);

            var filter = new FhirRequestContextRouteDataPopulatingFilterAttribute(_fhirRequestContextAccessor, _auditEventTypeMapping);

            filter.OnActionExecuting(_context);

            Assert.NotNull(_fhirRequestContextAccessor.FhirRequestContext.AuditEventType);
            Assert.Equal(expectedAuditEventType, _fhirRequestContextAccessor.FhirRequestContext.AuditEventType);
            Assert.Equal(RouteName, _fhirRequestContextAccessor.FhirRequestContext.RouteName);
        }