MediaUpload() public method

public MediaUpload ( IMediaItem media ) : Task>
media IMediaItem
return Task>
Exemplo n.º 1
0
        public async Task MediaUpload_Test()
        {
            using (var twitterApi = new TwitterApi())
                using (var image = TestUtils.CreateDummyImage())
                    using (var media = new MemoryImageMediaItem(image))
                    {
                        var mock = new Mock <IApiConnection>();
                        mock.Setup(x =>
                                   x.PostLazyAsync <TwitterUploadMediaResult>(
                                       new Uri("https://upload.twitter.com/1.1/media/upload.json", UriKind.Absolute),
                                       null,
                                       new Dictionary <string, IMediaItem> {
                            { "media", media }
                        })
                                   )
                        .ReturnsAsync(LazyJson.Create(new TwitterUploadMediaResult()));

                        twitterApi.apiConnection = mock.Object;

                        await twitterApi.MediaUpload(media)
                        .IgnoreResponse()
                        .ConfigureAwait(false);

                        mock.VerifyAll();
                    }
        }
Exemplo n.º 2
0
        public async Task MediaUpload_Test()
        {
            using (var twitterApi = new TwitterApi())
            using (var image = TestUtils.CreateDummyImage())
            using (var media = new MemoryImageMediaItem(image))
            {
                var mock = new Mock<IApiConnection>();
                mock.Setup(x =>
                    x.PostLazyAsync<TwitterUploadMediaResult>(
                        new Uri("https://upload.twitter.com/1.1/media/upload.json", UriKind.Absolute),
                        null,
                        new Dictionary<string, IMediaItem> { { "media", media } })
                )
                .ReturnsAsync(LazyJson.Create(new TwitterUploadMediaResult()));

                twitterApi.apiConnection = mock.Object;

                await twitterApi.MediaUpload(media)
                    .IgnoreResponse()
                    .ConfigureAwait(false);

                mock.VerifyAll();
            }
        }