public void CanUpdatePostWithCategories()
{
string hostname = UnitTestHelper.GenerateRandomString();
Assert.IsTrue(Config.CreateBlog("", "username", "password", hostname, ""));
UnitTestHelper.SetHttpContextWithBlogRequest(hostname, "");
Config.CurrentBlog.AllowServiceAccess = true;
string category1Name = UnitTestHelper.GenerateRandomString();
string category2Name = UnitTestHelper.GenerateRandomString();
UnitTestHelper.CreateCategory(Config.CurrentBlog.Id, category1Name);
UnitTestHelper.CreateCategory(Config.CurrentBlog.Id, category2Name);
Entry entry = new Entry(PostType.BlogPost);
entry.Title = "Title 1";
entry.Body = "Blah";
entry.IsActive = true;
entry.DateCreated = entry.DateSyndicated = entry.DateModified = DateTime.ParseExact("1975/01/23", "yyyy/MM/dd", CultureInfo.InvariantCulture);
entry.Categories.Add(category1Name);
int entryId = Entries.Create(entry);
MetaWeblog api = new MetaWeblog();
Post post = new Post();
post.title = "Title 2";
post.description = "Blah";
post.categories = new string[] { category2Name };
post.dateCreated = DateTime.Now;
bool result = api.editPost(entryId.ToString(CultureInfo.InvariantCulture), "username", "password", post, true);
entry = Entries.GetEntry(entryId, PostConfig.None, true);
Assert.AreEqual(1, entry.Categories.Count, "We expected one category. We didn't get what we expected.");
Assert.AreEqual(category2Name, entry.Categories[0], "Category has not been updated correctly.");
}