public async Task TestGetBlogMetadata()
        {
            BlogManager bm       = new BlogManager();
            var         blogInfo = new BlogInfo
            {
                Name = "getblogmetadata"
            };

            try {
                var response = bm.GetBlogMetadata(blogInfo, connString, contentFileRoot);
                Task.WaitAll(response);
                var responseInfo = (BlogInfo)response.Result;
                Assert.Null(responseInfo.Comments);

                // pass in null comments
                blogInfo.Comments = null;
                var comments = bm.Comments(blogInfo, connString, contentFileRoot);
                Task.WaitAll(comments);
                Assert.Null(comments.Result);

                blogInfo.Comments = "Hello world!";
                comments          = bm.Comments(blogInfo, connString, contentFileRoot);
                Task.WaitAll(comments);
                Assert.AreEqual("Hello world!", comments.Result);

                response = bm.GetBlogMetadata(blogInfo, connString, contentFileRoot);
                Task.WaitAll(response);
                responseInfo = (BlogInfo)response.Result;
                Assert.AreEqual("Hello world!", responseInfo.Comments);
            }
            finally {
                await bm.DeleteBlogIfExists(blogInfo, connString);
            }
        }
Beispiel #2
0
        public static async Task <IActionResult> GetBlogMetadata(
            [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
            ExecutionContext context,
            ILogger log)
        {
            try
            {
                var reqBodyData = await GetRequestObject(req);

                string connString = ConfigReader.GetAppSettingOrDefault(
                    context,
                    "azurestorageconnstring",
                    null
                    ); string contentFileRoot = ConfigReader.GetAppSettingOrDefault(
                    context,
                    "contentfileroot",
                    null
                    );

                BlogManager bm = new BlogManager();

                BlogInfo reqData = reqBodyData.ToObject <BlogInfo>();
                BlogInfo toRet   = await bm.GetBlogMetadata(reqData,
                                                            connString,
                                                            contentFileRoot);

                return(new OkObjectResult(toRet));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(new ExceptionResult(e, true));
            }
        }