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); }
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); }