public async Task BlogTestAsync() { TestLambdaContext context; APIGatewayProxyRequest request; APIGatewayProxyResponse response; Functions functions = new Functions(this.DDBClient, this.TableName); // Add a new blog post Blog myBlog = new Blog(); myBlog.Name = "The awesome post"; myBlog.Content = "Content for the awesome blog"; request = new APIGatewayProxyRequest { Body = JsonConvert.SerializeObject(myBlog) }; context = new TestLambdaContext(); response = await functions.AddBlogAsync(request, context); Assert.Equal(200, response.StatusCode); var blogId = response.Body; // Confirm we can get the blog post back out request = new APIGatewayProxyRequest { PathParameters = new Dictionary <string, string> { { Functions.ID_QUERY_STRING_NAME, blogId } } }; context = new TestLambdaContext(); response = await functions.GetBlogAsync(request, context); Assert.Equal(200, response.StatusCode); Blog readBlog = JsonConvert.DeserializeObject <Blog>(response.Body); Assert.Equal(myBlog.Name, readBlog.Name); Assert.Equal(myBlog.Content, readBlog.Content); // List the blog posts request = new APIGatewayProxyRequest { }; context = new TestLambdaContext(); response = await functions.GetBlogsAsync(request, context); Assert.Equal(200, response.StatusCode); Blog[] blogPosts = JsonConvert.DeserializeObject <Blog[]>(response.Body); Assert.Single(blogPosts); Assert.Equal(myBlog.Name, blogPosts[0].Name); Assert.Equal(myBlog.Content, blogPosts[0].Content); // Delete the blog post request = new APIGatewayProxyRequest { PathParameters = new Dictionary <string, string> { { Functions.ID_QUERY_STRING_NAME, blogId } } }; context = new TestLambdaContext(); response = await functions.RemoveBlogAsync(request, context); Assert.Equal(200, response.StatusCode); // Make sure the post was deleted. request = new APIGatewayProxyRequest { PathParameters = new Dictionary <string, string> { { Functions.ID_QUERY_STRING_NAME, blogId } } }; context = new TestLambdaContext(); response = await functions.GetBlogAsync(request, context); Assert.Equal((int)HttpStatusCode.NotFound, response.StatusCode); }