Пример #1
0
        public void CreatePost()
        {
            var client        = new Medium.Client();
            var title         = "Liverpool FC";
            var tags          = new[] { "football", "sport", "liverpool" };
            var canonicalUrl  = "http://jamietalbot.com/posts/liverpool-fc";
            var publishStatus = PublishStatus.Unlisted;
            var license       = License.Cc40By;
            var publishedAt   = new DateTime(2015, 1, 1);

            var author = client.GetCurrentUser(new Token {
                AccessToken = _accessToken
            });

            Assert.NotEqual(null, author);

            var body = new CreatePostRequestBody
            {
                Title           = title,
                ContentFormat   = ContentFormat.Html,
                Content         = "<h1>Liverpool FC</h1><p>You’ll never walk alone.</p>",
                Tags            = tags,
                CanonicalUrl    = canonicalUrl,
                PublishStatus   = publishStatus,
                License         = license,
                PublishedAt     = publishedAt,
                NotifyFollowers = false,
            };

            var post = client.CreatePost(author.Id, body, new Token {
                AccessToken = _accessToken
            });

            Assert.NotEqual(null, post);

            Assert.NotEqual(null, post.Id);
            Assert.Equal(title, post.Title);
            Assert.Equal(author.Id, post.AuthorId);
            Assert.Equal(true, tags.All(t => post.Tags.Contains(t)));
            Assert.Equal(true, post.Tags.All(t => tags.Contains(t)));
            Assert.NotEqual(null, post.Url);
            Assert.Equal(canonicalUrl, post.CanonicalUrl);
            Assert.Equal(publishStatus, post.PublishStatus);
            Assert.NotEqual(null, post.PublishedAt);
            Assert.Equal(publishedAt, post.PublishedAt);
            Assert.Equal(license, post.License);
            Assert.NotEqual(null, post.LicenseUrl);
        }
Пример #2
0
        public void CreatePost()
        {
            var client = new Medium.Client();
            var title = "Liverpool FC";
            var tags = new[] { "football", "sport", "liverpool" };
            var canonicalUrl = "http://jamietalbot.com/posts/liverpool-fc";
            var publishStatus = PublishStatus.Unlisted;
            var license = License.Cc40By;
            var publishedAt = new DateTime(2015, 1, 1);

            var author = client.GetCurrentUser(new Token { AccessToken = _accessToken });
            Assert.NotEqual(null, author);

            var body = new CreatePostRequestBody
            {
                Title = title,
                ContentFormat = ContentFormat.Html,
                Content = "<h1>Liverpool FC</h1><p>You’ll never walk alone.</p>",
                Tags = tags,
                CanonicalUrl = canonicalUrl,
                PublishStatus = publishStatus,
                License = license,
                PublishedAt = publishedAt,
                NotifyFollowers = false,
            };

            var post = client.CreatePost(author.Id, body, new Token { AccessToken = _accessToken });
            Assert.NotEqual(null, post);

            Assert.NotEqual(null, post.Id);
            Assert.Equal(title, post.Title);
            Assert.Equal(author.Id, post.AuthorId);
            Assert.Equal(true, tags.All(t => post.Tags.Contains(t)));
            Assert.Equal(true, post.Tags.All(t => tags.Contains(t)));
            Assert.NotEqual(null, post.Url);
            Assert.Equal(canonicalUrl, post.CanonicalUrl);
            Assert.Equal(publishStatus, post.PublishStatus);
            Assert.NotEqual(null, post.PublishedAt);
            Assert.Equal(publishedAt, post.PublishedAt);
            Assert.Equal(license, post.License);
            Assert.NotEqual(null, post.LicenseUrl);
        }