Exemplo n.º 1
0
        public async Task IApiActionAttributeTest()
        {
            var context = new TestActionContext(
                httpApi: null,
                httpApiConfig: new HttpApiConfig {
                HttpHost = new Uri("http://www.mywebapi.com")
            },
                apiActionDescriptor: new ApiActionDescriptor(typeof(IMyApi).GetMethod("PostAsync")));

            var attr = new TagsAttribute("key", "laojiu");
            await attr.BeforeRequestAsync(context);

            Assert.Equal("laojiu", context.Tags.Get("key").As <string>());
        }
Exemplo n.º 2
0
        public async Task IApiActionAttributeTest()
        {
            var context = new ApiActionContext
            {
                RequestMessage = new HttpApiRequestMessage
                {
                    RequestUri = new Uri("http://www.mywebapi.com"),
                    Method     = HttpMethod.Post
                },
                ApiActionDescriptor = ApiDescriptorCache.GetApiActionDescriptor(typeof(IMyApi).GetMethod("PostAsync"))
            };

            var attr = new TagsAttribute("key", "laojiu");
            await attr.BeforeRequestAsync(context);

            Assert.Equal("laojiu", context.Tags.Get("key").As <string>());
        }