Skip to content

Commit

Permalink
Changed CommandPerformer so that it isn't generic, but the PerformAct…
Browse files Browse the repository at this point in the history
…ion method is.

Fixes 91
  • Loading branch information
digitallyborn committed Jun 14, 2011
1 parent 7109595 commit ec096fd
Show file tree
Hide file tree
Showing 32 changed files with 387 additions and 146 deletions.
18 changes: 16 additions & 2 deletions Twitterizer2.Async/TwitterListAsync.cs
Expand Up @@ -124,13 +124,27 @@ public static IAsyncResult Delete(OAuthTokens tokens, string username, string li
/// <param name="timeout">The timeout.</param>
/// <param name="function">The function.</param>
/// <returns></returns>
[Obsolete("TwitterListAsync.GetList() has been replaced with TwitterListAsync.Show()")]
public static IAsyncResult GetList(OAuthTokens tokens, string username, string listIdOrSlug, OptionalProperties options, TimeSpan timeout, Action<TwitterAsyncResponse<TwitterList>> function)
{
Func<OAuthTokens, string, string, OptionalProperties, TwitterResponse<TwitterList>> methodToCall = TwitterList.GetList;
return Show(tokens, listIdOrSlug, options, timeout, function);
}

/// <summary>
/// Show the specified list. Private lists will only be shown if the authenticated user owns the specified list.
/// </summary>
/// <param name="tokens">The tokens.</param>
/// <param name="listIdOrSlug">The list id or slug.</param>
/// <param name="options">The options.</param>
/// <param name="timeout">The timeout.</param>
/// <param name="function">The function.</param>
/// <returns></returns>
public static IAsyncResult Show(OAuthTokens tokens, string listIdOrSlug, OptionalProperties options, TimeSpan timeout, Action<TwitterAsyncResponse<TwitterList>> function)
{
Func<OAuthTokens, string, OptionalProperties, TwitterResponse<TwitterList>> methodToCall = TwitterList.Show;

return methodToCall.BeginInvoke(
tokens,
username,
listIdOrSlug,
options,
result =>
Expand Down
13 changes: 13 additions & 0 deletions Twitterizer2.TestCases/CoreTests.cs
Expand Up @@ -80,5 +80,18 @@ public static void SSL()
Assert.That(timeline.RequestUrl.StartsWith("https://"));
Assert.That(user.RequestUrl.StartsWith("https://"));
}

[Test]
[Category("Distribution")]
public static void CheckAssemblySignature()
{
Assembly asm = Assembly.GetAssembly(typeof(TwitterUser));
if (asm != null)
{
AssemblyName asmName = asm.GetName();
byte[] key = asmName.GetPublicKey();
Assert.That(key.Length > 0);
}
}
}
}
8 changes: 4 additions & 4 deletions Twitterizer2.TestCases/TwitterListTests.cs
Expand Up @@ -12,9 +12,9 @@ public class TwitterListTests
[Test]
[Category("ReadOnly")]
[Category("REST")]
public void GetList()
public void Show()
{
TwitterList list = TwitterList.GetList(Configuration.GetTokens(), userName, listName, null).ResponseObject;
TwitterList list = TwitterList.Show(Configuration.GetTokens(), listName, null).ResponseObject;

Assert.IsNotNull(list);
}
Expand All @@ -38,7 +38,7 @@ public void GetMembers()
{
OAuthTokens tokens = Configuration.GetTokens();

TwitterResponse<TwitterList> list = TwitterList.GetList(tokens, "ghc", "ghc10-attendees");
TwitterResponse<TwitterList> list = TwitterList.Show(tokens, "ghc10-attendees");
TwitterResponse<TwitterUserCollection> usersInTheList = TwitterList.GetMembers(tokens, "ghc", "ghc10-attendees");

Assert.IsNotNull(usersInTheList);
Expand Down Expand Up @@ -87,7 +87,7 @@ public static void CreateAddAndDelete()
TwitterUser myUser = TwitterAccount.VerifyCredentials(tokens).ResponseObject;
var userIdToAdd = TwitterUser.Show(tokens, userName).ResponseObject.Id;

var listResponse = TwitterList.GetList(tokens, myUser.ScreenName, listName);
var listResponse = TwitterList.Show(tokens, listName);
if (listResponse.Result == RequestResult.FileNotFound)
{
// Create the new list
Expand Down
6 changes: 4 additions & 2 deletions Twitterizer2.nunit
@@ -1,7 +1,9 @@
<NUnitProject>
<Settings activeconfig="Debug" />
<Settings activeconfig="Release" />
<Config name="Debug" binpathtype="Auto">
<assembly path="Twitterizer2.TestCases\bin\Debug\Twitterizer2.TestCases.dll" />
</Config>
<Config name="Release" binpathtype="Auto" />
<Config name="Release" binpathtype="Auto">
<assembly path="Twitterizer2.TestCases\bin\Release\Twitterizer2.TestCases.dll" />
</Config>
</NUnitProject>
11 changes: 3 additions & 8 deletions Twitterizer2/Core/CommandPerformer.cs
Expand Up @@ -34,13 +34,7 @@

namespace Twitterizer.Core
{
/// <summary>
/// The Command Performer Class
/// </summary>
/// <typeparam name="T">The business object the performer should return.</typeparam>
/// <tocexclude />
internal static class CommandPerformer<T>
where T : ITwitterObject
internal static class CommandPerformer
{
/// <summary>
/// Performs the action.
Expand All @@ -49,7 +43,8 @@ internal static class CommandPerformer<T>
/// <returns>The parsed result of the action.</returns>
/// <seealso cref="Twitterizer.Core.TwitterCommand{T}"/>
/// <seealso cref="Twitterizer.Core.TwitterObject"/>
public static TwitterResponse<T> PerformAction(ICommand<T> command)
public static TwitterResponse<T> PerformAction<T>(ICommand<T> command)
where T : ITwitterObject
{
command.Init();

Expand Down
8 changes: 4 additions & 4 deletions Twitterizer2/Methods/Account/TwitterAccount.cs
Expand Up @@ -50,7 +50,7 @@ public static TwitterResponse<TwitterUser> VerifyCredentials(OAuthTokens tokens,
{
Commands.VerifyCredentialsCommand command = new Commands.VerifyCredentialsCommand(tokens, options);

return Core.CommandPerformer<TwitterUser>.PerformAction(command);
return Core.CommandPerformer.PerformAction(command);
}

/// <summary>
Expand All @@ -75,7 +75,7 @@ public static TwitterResponse<TwitterUser> UpdateProfileColors(OAuthTokens token
{
Commands.UpdateProfileColorsCommand command = new Twitterizer.Commands.UpdateProfileColorsCommand(tokens, options);

return CommandPerformer<TwitterUser>.PerformAction(command);
return CommandPerformer.PerformAction(command);
}

/// <summary>
Expand All @@ -91,7 +91,7 @@ public static TwitterResponse<TwitterUser> UpdateProfileImage(OAuthTokens tokens
{
Commands.UpdateProfileImageCommand command = new Twitterizer.Commands.UpdateProfileImageCommand(tokens, image, options);

return CommandPerformer<TwitterUser>.PerformAction(command);
return CommandPerformer.PerformAction(command);
}

/// <summary>
Expand All @@ -110,7 +110,7 @@ public static TwitterResponse<TwitterUser> UpdateProfileImage(OAuthTokens tokens
public static TwitterResponse<TwitterUser> UpdateProfile(OAuthTokens tokens, UpdateProfileOptions options)
{
Commands.UpdateProfileCommand command = new Commands.UpdateProfileCommand(tokens, options);
return Core.CommandPerformer<TwitterUser>.PerformAction(command);
return Core.CommandPerformer.PerformAction(command);
}
}
}
2 changes: 1 addition & 1 deletion Twitterizer2/Methods/Account/TwitterRateLimitStatus.cs
Expand Up @@ -81,7 +81,7 @@ public class TwitterRateLimitStatus : TwitterObject
public static TwitterResponse<TwitterRateLimitStatus> GetStatus(OAuthTokens tokens, OptionalProperties options)
{
Commands.RateLimitStatusCommand command = new Twitterizer.Commands.RateLimitStatusCommand(tokens, options);
TwitterResponse<TwitterRateLimitStatus> result = Core.CommandPerformer<TwitterRateLimitStatus>.PerformAction(command);
TwitterResponse<TwitterRateLimitStatus> result = Core.CommandPerformer.PerformAction(command);

return result;
}
Expand Down
16 changes: 8 additions & 8 deletions Twitterizer2/Methods/Block/TwitterBlock.cs
Expand Up @@ -51,7 +51,7 @@ public static TwitterResponse<TwitterUser> Create(OAuthTokens tokens, decimal us
{
Commands.CreateBlockCommand command = new Commands.CreateBlockCommand(tokens, string.Empty, userId, options);

return Core.CommandPerformer<TwitterUser>.PerformAction(command);
return Core.CommandPerformer.PerformAction(command);
}

/// <summary>
Expand Down Expand Up @@ -80,7 +80,7 @@ public static TwitterResponse<TwitterUser> Create(OAuthTokens tokens, string scr
{
Commands.CreateBlockCommand command = new Commands.CreateBlockCommand(tokens, screenName, -1, options);

return Core.CommandPerformer<TwitterUser>.PerformAction(command);
return Core.CommandPerformer.PerformAction(command);
}

/// <summary>
Expand Down Expand Up @@ -109,7 +109,7 @@ public static TwitterResponse<TwitterUser> Destroy(OAuthTokens tokens, decimal u
{
Commands.DestroyBlockCommand command = new Commands.DestroyBlockCommand(tokens, string.Empty, userId, options);

return Core.CommandPerformer<TwitterUser>.PerformAction(command);
return Core.CommandPerformer.PerformAction(command);
}

/// <summary>
Expand Down Expand Up @@ -138,7 +138,7 @@ public static TwitterResponse<TwitterUser> Destroy(OAuthTokens tokens, string sc
{
Commands.DestroyBlockCommand command = new Commands.DestroyBlockCommand(tokens, screenName, -1, options);

return Core.CommandPerformer<TwitterUser>.PerformAction(command);
return Core.CommandPerformer.PerformAction(command);
}

/// <summary>
Expand Down Expand Up @@ -167,7 +167,7 @@ public static TwitterResponse<TwitterUser> Exists(OAuthTokens tokens, decimal us
{
Commands.ExistsBlockCommand command = new Commands.ExistsBlockCommand(tokens, string.Empty, userId, options);

return Core.CommandPerformer<TwitterUser>.PerformAction(command);
return Core.CommandPerformer.PerformAction(command);
}

/// <summary>
Expand Down Expand Up @@ -196,7 +196,7 @@ public static TwitterResponse<TwitterUser> Exists(OAuthTokens tokens, string scr
{
Commands.ExistsBlockCommand command = new Commands.ExistsBlockCommand(tokens, screenName, -1, options);

return Core.CommandPerformer<TwitterUser>.PerformAction(command);
return Core.CommandPerformer.PerformAction(command);
}

/// <summary>
Expand All @@ -221,7 +221,7 @@ public static TwitterResponse<TwitterUser> Exists(OAuthTokens tokens, string scr
public static TwitterResponse<TwitterUserCollection> Blocking(OAuthTokens tokens, BlockingOptions options)
{
Commands.BlockingCommand command = new Commands.BlockingCommand(tokens, options);
return Core.CommandPerformer<TwitterUserCollection>.PerformAction(command);
return Core.CommandPerformer.PerformAction(command);
}

/// <summary>
Expand All @@ -245,7 +245,7 @@ public static TwitterResponse<TwitterIdCollection> BlockingIds(OAuthTokens token
{
Commands.BlockingIdsCommand command = new Commands.BlockingIdsCommand(tokens, options);

return Core.CommandPerformer<TwitterIdCollection>.PerformAction(command);
return Core.CommandPerformer.PerformAction(command);
}

/// <summary>
Expand Down
12 changes: 6 additions & 6 deletions Twitterizer2/Methods/DirectMessage/TwitterDirectMessage.cs
Expand Up @@ -141,7 +141,7 @@ public static TwitterResponse<TwitterDirectMessageCollection> DirectMessages(OAu
/// </returns>
public static TwitterResponse<TwitterDirectMessageCollection> DirectMessages(OAuthTokens tokens, DirectMessagesOptions options)
{
return CommandPerformer<TwitterDirectMessageCollection>.PerformAction(new Commands.DirectMessagesCommand(tokens, options));
return CommandPerformer.PerformAction(new Commands.DirectMessagesCommand(tokens, options));
}

/// <summary>
Expand Down Expand Up @@ -170,7 +170,7 @@ public static TwitterResponse<TwitterDirectMessage> Send(OAuthTokens tokens, dec
{
Commands.SendDirectMessageCommand command = new Commands.SendDirectMessageCommand(tokens, text, userId, options);

TwitterResponse<TwitterDirectMessage> result = Core.CommandPerformer<TwitterDirectMessage>.PerformAction(command);
TwitterResponse<TwitterDirectMessage> result = Core.CommandPerformer.PerformAction(command);

return result;
}
Expand Down Expand Up @@ -201,7 +201,7 @@ public static TwitterResponse<TwitterDirectMessage> Send(OAuthTokens tokens, str
{
Commands.SendDirectMessageCommand command = new Commands.SendDirectMessageCommand(tokens, text, screenName, options);

TwitterResponse<TwitterDirectMessage> result = Core.CommandPerformer<TwitterDirectMessage>.PerformAction(command);
TwitterResponse<TwitterDirectMessage> result = Core.CommandPerformer.PerformAction(command);

return result;
}
Expand All @@ -228,7 +228,7 @@ public static TwitterResponse<TwitterDirectMessage> Send(OAuthTokens tokens, str
/// </returns>
public static TwitterResponse<TwitterDirectMessageCollection> DirectMessagesSent(OAuthTokens tokens, DirectMessagesSentOptions options)
{
return CommandPerformer<TwitterDirectMessageCollection>.PerformAction(new Commands.DirectMessagesSentCommand(tokens, options));
return CommandPerformer.PerformAction(new Commands.DirectMessagesSentCommand(tokens, options));
}

/// <summary>
Expand All @@ -243,7 +243,7 @@ public TwitterResponse<TwitterDirectMessage> Delete(OAuthTokens tokens, Optional
{
Commands.DeleteDirectMessageCommand command = new Commands.DeleteDirectMessageCommand(tokens, this.Id, options);

TwitterResponse<TwitterDirectMessage> result = Core.CommandPerformer<TwitterDirectMessage>.PerformAction(command);
TwitterResponse<TwitterDirectMessage> result = Core.CommandPerformer.PerformAction(command);

return result;
}
Expand All @@ -261,7 +261,7 @@ public static TwitterResponse<TwitterDirectMessage> Delete(OAuthTokens tokens, d
{
Commands.DeleteDirectMessageCommand command = new Commands.DeleteDirectMessageCommand(tokens, id, options);

TwitterResponse<TwitterDirectMessage> result = Core.CommandPerformer<TwitterDirectMessage>.PerformAction(command);
TwitterResponse<TwitterDirectMessage> result = Core.CommandPerformer.PerformAction(command);

return result;
}
Expand Down
6 changes: 3 additions & 3 deletions Twitterizer2/Methods/Favorites/TwitterFavorite.cs
Expand Up @@ -61,7 +61,7 @@ private TwitterFavorite()
/// <returns>The favorite status when successful.</returns>
public static TwitterResponse<TwitterStatus> Create(OAuthTokens tokens, decimal statusId, OptionalProperties options)
{
return CommandPerformer<TwitterStatus>.PerformAction(
return CommandPerformer.PerformAction(
new Commands.CreateFavoriteCommand(tokens, statusId, options));
}

Expand All @@ -85,7 +85,7 @@ public static TwitterResponse<TwitterStatus> Create(OAuthTokens tokens, decimal
/// <returns>The un-favorited status in the requested format when successful.</returns>
public static TwitterResponse<TwitterStatus> Delete(OAuthTokens tokens, decimal statusId, OptionalProperties options)
{
return CommandPerformer<TwitterStatus>.PerformAction(
return CommandPerformer.PerformAction(
new Commands.DeleteFavoriteCommand(tokens, statusId, options));
}

Expand All @@ -110,7 +110,7 @@ public static TwitterResponse<TwitterStatus> Delete(OAuthTokens tokens, decimal
/// <returns>The 20 most recent favorite statuses</returns>
public static TwitterResponse<TwitterStatusCollection> List(OAuthTokens tokens, ListFavoritesOptions options)
{
return CommandPerformer<TwitterStatusCollection>.PerformAction(
return CommandPerformer.PerformAction(
new Commands.ListFavoritesCommand(tokens, options));
}

Expand Down

0 comments on commit ec096fd

Please sign in to comment.