Ejemplo n.º 1
0
        public void GivenIHaveMappedLinkRelationsByContentType(Table table)
        {
            var mapper = new OpenApiLinkOperationMapper();
            IEnumerable <(string RelationName, string ContentType, string OperationId)> mappings = table.CreateSet <(string RelationName, string TargetType, string OperationId)>();

            foreach ((string relationName, string contentType, string operationId) in mappings)
            {
                mapper.MapByContentTypeAndRelationTypeAndOperationId(contentType, relationName, operationId);
            }

            this.scenarioContext.Set <IOpenApiLinkOperationMapper>(mapper);
        }
Ejemplo n.º 2
0
        public void GivenIHaveMappedLinkRelationsByType(Table table)
        {
            var        mapper           = new OpenApiLinkOperationMapper();
            MethodInfo genericMapMethod = typeof(OpenApiLinkOperationMapper).GetMethod(nameof(IOpenApiLinkOperationMap.MapByContentTypeAndRelationTypeAndOperationId), new[] { typeof(string), typeof(string) }) ?? throw new InvalidOperationException($"Unable to get method info for {nameof(IOpenApiLinkOperationMap.MapByContentTypeAndRelationTypeAndOperationId)}");
            IEnumerable <(string RelationName, string TargetType, string OperationId)> mappings = table.CreateSet <(string RelationName, string TargetType, string OperationId)>();

            foreach ((string relationName, string targetTypeName, string operationId) in mappings)
            {
                Type       targetType = Type.GetType(targetTypeName) ?? throw new InvalidOperationException($"Unable to get type info for {targetTypeName}");
                MethodInfo mapMethod  = genericMapMethod.MakeGenericMethod(targetType);
                mapMethod.Invoke(mapper, new[] { relationName, operationId });
            }

            this.scenarioContext.Set <IOpenApiLinkOperationMapper>(mapper);
        }