public void GetByTags_WhenMultiplePostContainsSearchedTags_ShouldReturn200CodeAndCollection()
{
var posts = new List<PostModel>()
{
new PostModel()
{
Title = "postting post",
Text = "Pesho posted a new post 1!!!"
},
new PostModel()
{
Title = "post postting yeah",
Text = "Pesho posted a new post 2!!!",
Tags = new List<string>() { "new" }
},
new PostModel()
{
Title = "post new and oldy",
Text = "Pesho posted a new post 3!!!",
Tags = new List<string>() { "taggy", "old" }
}
};
// Add some tags
foreach (var postModel in posts)
{
this.httpServer.Post("api/posts", postModel, this.sessionKeyHeader);
}
var httpResponse = this.httpServer.Get("api/posts?tags=post,postting", this.sessionKeyHeader);
var postsWithTags = httpResponse.Content.ReadAsAsync<IEnumerable<PostModel>>().Result;
Assert.AreEqual(HttpStatusCode.OK, httpResponse.StatusCode);
Assert.IsNotNull(postsWithTags);
Assert.AreEqual(2, postsWithTags.Count());
}