public void GetAuthors_ReturnsAllAuthors_WhenNoLimitIsTrue() { var auth = new GhostContentAPI(Host, ValidContentApiKey); var authorResponse = auth.GetAuthors(new AuthorQueryParams { Limit = 1, NoLimit = true, Fields = AuthorFields.Id }); Assert.GreaterOrEqual(authorResponse.Authors.Count, 2); }
public void GetAuthors_ReturnsPostCount_WhenIncludingCountPosts() { var auth = new GhostContentAPI(Host, ValidContentApiKey); var author = auth.GetAuthors(new AuthorQueryParams { Limit = 1, IncludePostCount = true }).Authors[0]; Assert.IsNotNull(author.Count.Posts); }
public void GetSettings_DoesNotThrow_ReturnsNull_WhenKeyIsInvalid(ExceptionLevel exceptionLevel) { var auth = new GhostContentAPI(Host, InvalidApiKey) { ExceptionLevel = exceptionLevel }; Assert.IsNull(auth.GetSettings()); Assert.IsNotNull(auth.LastException); }
public void GetPosts_ReturnsLimitedPosts_WhenLimitSpecified() { var auth = new GhostContentAPI(Host, ValidContentApiKey); var postResponse = auth.GetPosts(new PostQueryParams { Limit = 1, Fields = PostFields.Id }); Assert.AreEqual(1, postResponse.Posts.Count); }
public void GetPosts_ReturnsAllPosts_WhenNoLimitIsTrue() { var auth = new GhostContentAPI(Host, ValidContentApiKey); var postResponse = auth.GetPosts(new PostQueryParams { Limit = 1, NoLimit = true, Fields = PostFields.Id }); Assert.GreaterOrEqual(postResponse.Posts.Count, MINIMUM_POST_COUNT_THRESHHOLD); }
public void GetAuthors_ReturnsLimitedAuthors_WhenLimitSpecified() { var auth = new GhostContentAPI(Host, ValidContentApiKey); var authorResponse = auth.GetAuthors(new AuthorQueryParams { Limit = 1, Fields = AuthorFields.Id }); Assert.AreEqual(1, authorResponse.Authors.Count); }
public void GetPosts_ReturnsNull_WhenKeyIsInvalid_AndGhostExceptionsSuppressed(ExceptionLevel exceptionLevel) { var auth = new GhostContentAPI(Host, InvalidApiKey) { ExceptionLevel = exceptionLevel }; Assert.IsNull(auth.GetPosts()); Assert.IsNotNull(auth.LastException); }
public void GetPages_ReturnsExpectedPage_WhenOrderingByField() { var auth = new GhostContentAPI(Host, ValidContentApiKey); var page = auth.GetPages(new PostQueryParams { Limit = 1, Order = new List <Tuple <PostFields, OrderDirection> > { Tuple.Create(PostFields.CreatedAt, OrderDirection.asc) } }).Pages[0]; Assert.AreEqual("5967634499d09e0ee05c3b74", page.Id); }
public void GetPages_ReturnsExpectedPage_WhenGettingSecondPage() { var auth = new GhostContentAPI(Host, ValidContentApiKey); var page = auth.GetPages(new PostQueryParams { Page = 2, Limit = 2, Order = new List <Tuple <PostFields, OrderDirection> > { Tuple.Create(PostFields.CreatedAt, OrderDirection.asc) }, Fields = PostFields.Id }).Pages[0]; Assert.AreEqual("5a763359af2ce009c238f606", page.Id); }
public void GetPosts_ThrowsException_WhenKeyIsInvalid(ExceptionLevel exceptionLevel) { var auth = new GhostContentAPI(Host, InvalidApiKey) { ExceptionLevel = exceptionLevel }; var ex = Assert.Throws <GhostSharpException>(() => auth.GetPosts()); Assert.IsNotEmpty(ex.Errors); Assert.AreEqual("Unknown Content API Key", ex.Errors[0].Message); }
public void GetPosts_ReturnsExpectedPost_WhenGettingSecondPage() { var auth = new GhostContentAPI(Host, ValidContentApiKey); var post = auth.GetPosts(new PostQueryParams { Page = 2, Limit = 2, Order = new List <Tuple <PostFields, OrderDirection> > { Tuple.Create(PostFields.CreatedAt, OrderDirection.asc) }, Fields = PostFields.Id }).Posts[0]; // potentially fragile Assert.AreEqual("5e90d3eb1318020e53971b5e", post.Id); }
public void GetPosts_ReturnsExpectedPost_WhenOrderingByField() { var auth = new GhostContentAPI(Host, ValidContentApiKey); var post = auth.GetPosts(new PostQueryParams { Limit = 1, Order = new List <Tuple <PostFields, OrderDirection> > { Tuple.Create(PostFields.CreatedAt, OrderDirection.asc) } }).Posts[0]; // potentially fragile Assert.AreEqual("5967634699d09e0ee05c3b76", post.Id); }
public void GetPages_ReturnsAuthorsAndTags_WhenIncludingAuthorsAndTags() { var auth = new GhostContentAPI(Host, ValidContentApiKey); var page = auth.GetPages(new PostQueryParams { Limit = 1, IncludeTags = true, IncludeAuthors = true }).Pages[0]; Assert.IsNotNull(page.Tags); Assert.IsNotNull(page.Authors); Assert.IsNotNull(page.PrimaryAuthor); }
public void GetPages_ReturnsExpectedPage_WhenOrderingByField() { var auth = new GhostContentAPI(Host, ValidContentApiKey); var page = auth.GetPages(new PostQueryParams { Limit = 1, Order = new List <Tuple <PostFields, OrderDirection> > { Tuple.Create(PostFields.CreatedAt, OrderDirection.asc) } }).Pages[0]; // potentially fragile Assert.AreEqual("5e90d3eb1318020e53971b5b", page.Id); }
public void GetPosts_ReturnsTags_WhenIncludingTags() { var auth = new GhostContentAPI(Host, ValidContentApiKey); var post = auth.GetPosts(new PostQueryParams { Limit = 1, IncludeTags = true }).Posts[0]; Assert.IsNotNull(post.Tags); Assert.IsNotNull(post.PrimaryTag); Assert.IsNull(post.Authors); Assert.IsNull(post.PrimaryAuthor); }
public void GetAuthors_ReturnsExpectedAuthor_WhenGettingSecondPage() { var auth = new GhostContentAPI(Host, ValidContentApiKey); var author = auth.GetAuthors(new AuthorQueryParams { Limit = 1, Page = 2, Order = new List <Tuple <AuthorFields, OrderDirection> > { Tuple.Create(AuthorFields.Slug, OrderDirection.asc) } }).Authors[0]; Assert.AreEqual(ValidAuthor2Id, author.Id); Assert.AreEqual(ValidAuthor2Slug, author.Slug); Assert.AreEqual(ValidAuthor2Name, author.Name); Assert.AreEqual(ValidAuthor2Url, author.Url); }
public void GetPages_ReturnsExpectedPages_WhenApplyingFilter() { var auth = new GhostContentAPI(Host, ValidContentApiKey); var pageResponse = auth.GetPages(new PostQueryParams { Filter = $"slug:[{ValidPage1Slug}]" }); Assert.AreEqual(1, pageResponse.Pages.Count); var page = pageResponse.Pages[0]; Assert.AreEqual(ValidPage1Id, page.Id); Assert.AreEqual(ValidPage1Slug, page.Slug); Assert.AreEqual(ValidPage1Url, page.Url); }
public void GetPosts_ReturnsExpectedPosts_WhenApplyingFilter() { var auth = new GhostContentAPI(Host, ValidContentApiKey); var postResponse = auth.GetPosts(new PostQueryParams { Filter = $"slug:[{ValidPost1Slug}]" }); Assert.AreEqual(1, postResponse.Posts.Count); var post = postResponse.Posts[0]; Assert.AreEqual(ValidPost1Id, post.Id); Assert.AreEqual(ValidPost1Slug, post.Slug); Assert.AreEqual(ValidPost1Title, post.Title); Assert.AreEqual(ValidPost1Url, post.Url); }
public void GetAuthors_ReturnsExpectedAuthors_WhenApplyingFilter() { var auth = new GhostContentAPI(Host, ValidContentApiKey); var authorResponse = auth.GetAuthors(new AuthorQueryParams { Filter = "slug:[grant2]" }); Assert.AreEqual(1, authorResponse.Authors.Count); var author = authorResponse.Authors[0]; Assert.AreEqual(ValidAuthor2Id, author.Id); Assert.AreEqual(ValidAuthor2Slug, author.Slug); Assert.AreEqual(ValidAuthor2Name, author.Name); Assert.AreEqual(ValidAuthor2Url, author.Url); }
public void GetPosts_ReturnsLimitedFields_WhenFieldsSpecified() { var auth = new GhostContentAPI(Host, ValidContentApiKey); var post = auth.GetPosts(new PostQueryParams { Limit = 1, Fields = PostFields.Id }).Posts[0]; Assert.IsNotNull(post.Id); Assert.IsFalse(post.Page); Assert.IsNull(post.Authors); Assert.IsNull(post.CodeInjectionFoot); Assert.IsNull(post.CodeInjectionHead); Assert.IsNull(post.CommentId); Assert.IsNull(post.CreatedAt); Assert.IsNull(post.CustomExcerpt); Assert.IsNull(post.CustomTemplate); Assert.IsNull(post.Excerpt); Assert.IsNull(post.Featured); Assert.IsNull(post.FeatureImage); Assert.IsNull(post.Html); Assert.IsNull(post.MetaDescription); Assert.IsNull(post.MetaTitle); Assert.IsNull(post.MobileDoc); Assert.IsNull(post.OgDescription); Assert.IsNull(post.OgImage); Assert.IsNull(post.OgTitle); Assert.IsNull(post.PlainText); Assert.IsNull(post.PrimaryAuthor); Assert.IsNull(post.PrimaryTag); Assert.IsNull(post.PublishedAt); Assert.IsNull(post.Slug); Assert.IsNull(post.Tags); Assert.IsNull(post.Title); Assert.IsNull(post.TwitterDescription); Assert.IsNull(post.TwitterImage); Assert.IsNull(post.TwitterTitle); Assert.IsNull(post.UpdatedAt); Assert.IsNull(post.Url); Assert.IsNull(post.Uuid); }
public void GetAuthors_ReturnsLimitedFields_WhenFieldsSpecified() { var auth = new GhostContentAPI(Host, ValidContentApiKey); var author = auth.GetAuthors(new AuthorQueryParams { Limit = 1, Fields = AuthorFields.Id }).Authors[0]; Assert.IsNull(author.Bio); Assert.IsNull(author.Count); Assert.IsNull(author.CoverImage); Assert.IsNull(author.Facebook); Assert.IsNull(author.Location); Assert.IsNull(author.MetaDescription); Assert.IsNull(author.MetaTitle); Assert.IsNull(author.Name); Assert.IsNull(author.ProfileImage); Assert.IsNull(author.Slug); Assert.IsNull(author.Twitter); Assert.IsNull(author.Website); Assert.IsNull(author.Url); Assert.IsNotNull(author.Id); }
public void SetUp() { auth = new GhostContentAPI(Host, ValidContentApiKey); }
public void GetSettings_ReturnsSettings_WhenKeyIsValid() { var auth = new GhostContentAPI(Host, ValidContentApiKey); Assert.AreEqual(SiteTitle, auth.GetSettings().Title); }
public void SetUp() { auth = new GhostContentAPI("http://invalid_uri.com", "invalid_key"); mockClient = new Mock <IRestClient>(MockBehavior.Strict); auth.Client = mockClient.Object; }