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(); }
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(); } }