Пример #1
0
        public void CreatePostUnderPublication()
        {
            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.Public;
            var license       = License.Cc40By;

            var author = client.GetCurrentUser(GetToken());

            Assert.NotEqual(null, author);

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

            var post = client.CreatePostUnderPublication(_testPublicationId, body, GetToken());

            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(license, post.License);
            Assert.NotEqual(null, post.LicenseUrl);

            Assert.NotEqual(null, post.PublicationId);
            Assert.Equal(_testPublicationId, post.PublicationId);
        }
Пример #2
0
        public void CreatePostUnderPublication()
        {
            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.Public;
            var license = License.Cc40By;

            var author = client.GetCurrentUser(GetToken());
            Assert.NotEqual(null, author);

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

            var post = client.CreatePostUnderPublication(_testPublicationId, body, GetToken());
            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(license, post.License);
            Assert.NotEqual(null, post.LicenseUrl);

            Assert.NotEqual(null, post.PublicationId);
            Assert.Equal(_testPublicationId, post.PublicationId);
        }