Example #1
0
        public void GivenTheOperationLocatorMapsTheOperationIdToAnOperationNamed(string operationId, string operationName)
        {
            Assert.AreEqual(nameof(this.TestOperation), operationName, "Menes uses the method name as the operation name, so this test can only work if the operation specified in the spec matches the name of the operation method supplied");

            var operation = new OpenApiServiceOperation(
                this,
                OperationMethodInfo,
                new Mock <IOpenApiConfiguration>().Object);

            this.InvokerContext.OperationLocator
            .Setup(m => m.TryGetOperation(operationId, out operation))
            .Returns(true);
        }
        public void GivenTheOperationPathTemplateHasAnOperationWithAnOperationIdOf(string operationId)
        {
            this.openApiOperation = new OpenApiOperation {
                OperationId = operationId
            };
            this.operationPathTemplate = new OpenApiOperationPathTemplate(this.openApiOperation, new OpenApiPathTemplate("/", new OpenApiPathItem()));

            MethodInfo serviceMethod = typeof(OpenApiOperationInvokerSteps).GetMethod(
                nameof(this.ServiceMethodImplementation),
                BindingFlags.NonPublic | BindingFlags.Instance)
                                       ?? throw new InvalidOperationException($"Unable to get method info for {nameof(this.ServiceMethodImplementation)}");

            var openApiServiceOperation = new OpenApiServiceOperation(this, serviceMethod, this.openApiConfiguration.Object);

            this.InvokerContext.OperationLocator
            .Setup(m => m.TryGetOperation(operationId, out openApiServiceOperation))
            .Returns(true);
        }