public void getCategories_ReturnsCategoriesInRepository()
{
//arrange
var blog = new Blog { AllowServiceAccess = true, Host = "localhost", UserName = "******", Password = "******" };
var category = new LinkCategory
{
BlogId = blog.Id,
IsActive = true,
Description = "Test category",
Title = "CategoryA",
CategoryType = CategoryType.PostCollection,
Id = 42
};
var subtextContext = new Mock<ISubtextContext>();
subtextContext.Setup(c => c.Blog).Returns(blog);
subtextContext.Setup(c => c.UrlHelper.CategoryUrl(It.IsAny<LinkCategory>())).Returns("/Category/42.aspx");
subtextContext.Setup(c => c.UrlHelper.CategoryRssUrl(It.IsAny<LinkCategory>())).Returns("/rss.aspx?catId=42");
subtextContext.Setup(c => c.Repository.GetCategories(CategoryType.PostCollection, false)).Returns(new[] { category });
subtextContext.Setup(c => c.ServiceLocator).Returns(new Mock<IDependencyResolver>().Object);
var api = new MetaWeblog(subtextContext.Object);
//act
CategoryInfo[] categories = api.getCategories(blog.Id.ToString(), "username", "password");
//assert
Assert.AreEqual(1, categories.Length);
Assert.AreEqual("http://localhost/Category/42.aspx", categories[0].htmlUrl);
Assert.AreEqual("http://localhost/rss.aspx?catId=42", categories[0].rssUrl);
}