MediaMetadataCreate() public method

public MediaMetadataCreate ( long mediaId, string altText ) : Task
mediaId long
altText string
return Task
示例#1
0
        public async Task MediaMetadataCreate_Test()
        {
            var mock = new Mock <IApiConnection>();

            mock.Setup(x =>
                       x.PostJsonAsync(
                           new Uri("https://upload.twitter.com/1.1/media/metadata/create.json", UriKind.Absolute),
                           "{\"media_id\": \"12345\", \"alt_text\": {\"text\": \"hogehoge\"}}")
                       )
            .Returns(Task.CompletedTask);

            using var twitterApi     = new TwitterApi();
            twitterApi.apiConnection = mock.Object;

            await twitterApi.MediaMetadataCreate(mediaId : 12345L, altText : "hogehoge")
            .ConfigureAwait(false);

            mock.VerifyAll();
        }
示例#2
0
        public async Task MediaMetadataCreate_Test()
        {
            using (var twitterApi = new TwitterApi())
            {
                var mock = new Mock<IApiConnection>();
                mock.Setup(x =>
                    x.PostJsonAsync(
                        new Uri("https://upload.twitter.com/1.1/media/metadata/create.json", UriKind.Absolute),
                        "{\"media_id\": \"12345\", \"alt_text\": {\"text\": \"hogehoge\"}}")
                )
                .Returns(Task.FromResult(0));

                twitterApi.apiConnection = mock.Object;

                await twitterApi.MediaMetadataCreate(mediaId: 12345L, altText: "hogehoge")
                    .ConfigureAwait(false);

                mock.VerifyAll();
            }
        }