}
[Fact]
+ public async Task ListsDestroy_Test()
+ {
+ using (var twitterApi = new TwitterApi())
+ {
+ var mock = new Mock<IApiConnection>();
+ mock.Setup(x =>
+ x.PostLazyAsync<TwitterList>(
+ new Uri("lists/destroy.json", UriKind.Relative),
+ new Dictionary<string, string> {
+ { "list_id", "12345" },
+ })
+ )
+ .ReturnsAsync(LazyJson.Create(new TwitterList()));
+
+ twitterApi.apiConnection = mock.Object;
+
+ await twitterApi.ListsDestroy(12345L)
+ .IgnoreResponse()
+ .ConfigureAwait(false);
+
+ mock.VerifyAll();
+ }
+ }
+
+ [Fact]
public async Task ListsStatuses_Test()
{
using (var twitterApi = new TwitterApi())
return this.apiConnection.PostLazyAsync<TwitterList>(endpoint, param);
}
+ public Task<LazyJson<TwitterList>> ListsDestroy(long listId)
+ {
+ var endpoint = new Uri("lists/destroy.json", UriKind.Relative);
+ var param = new Dictionary<string, string>
+ {
+ ["list_id"] = listId.ToString(),
+ };
+
+ return this.apiConnection.PostLazyAsync<TwitterList>(endpoint, param);
+ }
+
public Task<TwitterStatus[]> ListsStatuses(long listId, int? count = null, long? maxId = null, long? sinceId = null, bool? includeRTs = null)
{
var endpoint = new Uri("lists/statuses.json", UriKind.Relative);
}
#region Lists
- public HttpStatusCode DeleteListID(string user, string list_id, ref string content)
- {
- Dictionary<string, string> param = new Dictionary<string, string>();
- param.Add("screen_name", user);
- param.Add("list_id", list_id);
-
- return httpCon.GetContent(PostMethod,
- this.CreateTwitterUri("/1.1/lists/destroy.json"),
- param,
- ref content,
- null,
- null);
- }
-
public HttpStatusCode GetListMembers(string user, string list_id, long cursor, ref string content)
{
Dictionary<string, string> param = new Dictionary<string, string>();
{
try
{
- this.tw.DeleteList(list.Id.ToString());
+ await this.tw.DeleteList(list.Id);
}
catch (WebApiException ex)
{
.ToList();
}
- public void DeleteList(string list_id)
+ public async Task DeleteList(long listId)
{
- HttpStatusCode res;
- var content = "";
+ await this.Api.ListsDestroy(listId)
+ .IgnoreResponse()
+ .ConfigureAwait(false);
- try
- {
- res = twCon.DeleteListID(this.Username, list_id, ref content);
- }
- catch(Exception ex)
- {
- throw new WebApiException("Err:" + ex.Message + "(" + MethodBase.GetCurrentMethod().Name + ")", ex);
- }
+ var tabinfo = TabInformations.GetInstance();
- this.CheckStatusCode(res, content);
+ tabinfo.SubscribableLists = tabinfo.SubscribableLists
+ .Where(x => x.Id != listId)
+ .ToList();
}
public async Task<ListElement> EditList(long listId, string new_name, bool isPrivate, string description)