示例#1
0
        public void AddsStorageOutput_AndHttpReturn_FromReturnType()
        {
            FunctionContext context = GetContextWithOutputBindings(nameof(HttpAndStorage.MyQueueOutput), nameof(HttpAndStorage.MyBlobOutput),
                                                                   nameof(HttpAndStorage.MyHttpResponseData));
            var emptyHttp = new TestHttpResponseData(context, HttpStatusCode.OK);

            HttpAndStorage result = new HttpAndStorage()
            {
                MyQueueOutput      = "queueStuff",
                MyBlobOutput       = "blobStuff",
                MyRandomValue      = "ShouldNotAppear",
                MyHttpResponseData = emptyHttp
            };

            context.GetBindings().InvocationResult = result;

            Assert.Equal(0, context.GetBindings().OutputBindingData.Count);

            OutputBindingsMiddleware.AddOutputBindings(context);
            object returnedVal = context.GetBindings().InvocationResult;

            Assert.Null(returnedVal);
            Assert.Equal(3, context.GetBindings().OutputBindingData.Count);

            AssertDictionary(context.GetBindings().OutputBindingData, new Dictionary <string, object>()
            {
                { "MyQueueOutput", "queueStuff" },
                { "MyBlobOutput", "blobStuff" },
                { "MyHttpResponseData", emptyHttp }
            });
        }
示例#2
0
        public void SetsOutput_FromMethodBinding()
        {
            // special binding to indicate the return value is set as an output binding
            FunctionContext context   = GetContextWithOutputBindings("$return");
            var             emptyHttp = new TestHttpResponseData(context, HttpStatusCode.OK);

            context.GetBindings().InvocationResult = emptyHttp;

            Assert.Empty(context.GetBindings().OutputBindingData);

            OutputBindingsMiddleware.AddOutputBindings(context);
            object returnedVal = context.GetBindings().InvocationResult;

            Assert.Equal(returnedVal, emptyHttp);
            Assert.Empty(context.GetBindings().OutputBindingData);

            AssertDictionary(context.GetBindings().OutputBindingData, new Dictionary <string, object>());
        }