1. lfoust
  2. stacky

Commits

lfoust  committed f1f5b42

Added StackAuth Client and updated Site entity

  • Participants
  • Parent commits 65cbffa
  • Branches default

Comments (0)

Files changed (21)

File trunk/source/Stacky.Net35/Stacky.Net35.csproj

View file
     <Compile Include="..\Stacky\Entities\Answer.cs">
       <Link>Entities\Answer.cs</Link>
     </Compile>
+    <Compile Include="..\Stacky\Entities\AssociatedUser.cs">
+      <Link>Entities\AssociatedUser.cs</Link>
+    </Compile>
     <Compile Include="..\Stacky\Entities\Badge.cs">
       <Link>Entities\Badge.cs</Link>
     </Compile>
     <Compile Include="..\Stacky\Enums\SearchSort.cs">
       <Link>Enums\SearchSort.cs</Link>
     </Compile>
+    <Compile Include="..\Stacky\Enums\SiteState.cs">
+      <Link>Enums\SiteState.cs</Link>
+    </Compile>
     <Compile Include="..\Stacky\Enums\SortArgsAttribute.cs">
       <Link>Enums\SortArgsAttribute.cs</Link>
     </Compile>
     <Compile Include="..\Stacky\Responses\AnswerResponse.cs">
       <Link>Responses\AnswerResponse.cs</Link>
     </Compile>
+    <Compile Include="..\Stacky\Responses\AssociatedUsersResponse.cs">
+      <Link>Responses\AssociatedUsersResponse.cs</Link>
+    </Compile>
     <Compile Include="..\Stacky\Responses\BadgeResponse.cs">
       <Link>Responses\BadgeResponse.cs</Link>
     </Compile>
     <Compile Include="..\Stacky\Responses\RevisionResponse.cs">
       <Link>Responses\RevisionResponse.cs</Link>
     </Compile>
+    <Compile Include="..\Stacky\Responses\SitesResponse.cs">
+      <Link>Responses\SitesResponse.cs</Link>
+    </Compile>
     <Compile Include="..\Stacky\Responses\StatsResponse.cs">
       <Link>Responses\StatsResponse.cs</Link>
     </Compile>
     <Compile Include="..\Stacky\Sites.cs">
       <Link>Sites.cs</Link>
     </Compile>
+    <Compile Include="..\Stacky\StackAuthClient.cs">
+      <Link>StackAuthClient.cs</Link>
+    </Compile>
+    <Compile Include="..\Stacky\StackAuthClientAsync.cs">
+      <Link>StackAuthClientAsync.cs</Link>
+    </Compile>
     <Compile Include="..\Stacky\StackyClientAsync\StackyClientAsync.cs">
       <Link>StackyClientAsync\StackyClientAsync.cs</Link>
     </Compile>

File trunk/source/Stacky.Silverlight/Stacky.Silverlight.csproj

View file
     <Compile Include="..\Stacky\Entities\Answer.cs">
       <Link>Entities\Answer.cs</Link>
     </Compile>
+    <Compile Include="..\Stacky\Entities\AssociatedUser.cs">
+      <Link>Entities\AssociatedUser.cs</Link>
+    </Compile>
     <Compile Include="..\Stacky\Entities\Badge.cs">
       <Link>Entities\Badge.cs</Link>
     </Compile>
     <Compile Include="..\Stacky\Enums\SearchSort.cs">
       <Link>Enums\SearchSort.cs</Link>
     </Compile>
+    <Compile Include="..\Stacky\Enums\SiteState.cs">
+      <Link>Enums\SiteState.cs</Link>
+    </Compile>
     <Compile Include="..\Stacky\Enums\SortArgsAttribute.cs">
       <Link>Enums\SortArgsAttribute.cs</Link>
     </Compile>
     <Compile Include="..\Stacky\Responses\AnswerResponse.cs">
       <Link>Responses\AnswerResponse.cs</Link>
     </Compile>
+    <Compile Include="..\Stacky\Responses\AssociatedUsersResponse.cs">
+      <Link>Responses\AssociatedUsersResponse.cs</Link>
+    </Compile>
     <Compile Include="..\Stacky\Responses\BadgeResponse.cs">
       <Link>Responses\BadgeResponse.cs</Link>
     </Compile>
     <Compile Include="..\Stacky\Responses\RevisionResponse.cs">
       <Link>Responses\RevisionResponse.cs</Link>
     </Compile>
+    <Compile Include="..\Stacky\Responses\SitesResponse.cs">
+      <Link>Responses\SitesResponse.cs</Link>
+    </Compile>
     <Compile Include="..\Stacky\Responses\StatsResponse.cs">
       <Link>Responses\StatsResponse.cs</Link>
     </Compile>
     <Compile Include="..\Stacky\Sites.cs">
       <Link>Sites.cs</Link>
     </Compile>
+    <Compile Include="..\Stacky\StackAuthClientAsync.cs">
+      <Link>StackAuthClientAsync.cs</Link>
+    </Compile>
     <Compile Include="..\Stacky\StackyClientAsync\AnswerMethods.cs">
       <Link>StackyClient\AnswerMethods.cs</Link>
     </Compile>

File trunk/source/Stacky.WindowsPhone/StackAuthClientAsync.cs

View file
+using System;
+using System.Collections.Generic;
+
+namespace Stacky
+{
+#if SILVERLIGHT
+    public class StackAuthClient
+#else
+    public class StackAuthClientAsync
+#endif
+    {
+#if SILVERLIGHT
+		    public StackAuthClient(IUrlClient client, IProtocol protocol)
+#else
+        public StackAuthClientAsync(IUrlClientAsync client, IProtocol protocol)
+#endif
+        {
+            BaseUrl = "http://stackauth.com";
+            WebClient = client;
+            Protocol = protocol;
+        }
+
+#if SILVERLIGHT
+		    public IUrlClient WebClient { get; set; }
+#else
+        public IUrlClientAsync WebClient { get; set; }
+#endif
+        public IProtocol Protocol { get; set; }
+        public string BaseUrl { get; private set; }
+
+        #region Methods
+
+        public void MakeRequest<T>(string method, string[] urlArguments, Action<T> onSuccess, Action<ApiException> onError)
+                where T : new()
+        {
+            try
+            {
+                HttpResponse httpResponse = null;
+                GetResponse(method, urlArguments, response =>
+                {
+                    httpResponse = response;
+                    ParseResponse<T>(httpResponse, onSuccess, onError);
+                }, onError);
+            }
+            catch (Exception e)
+            {
+                onError(new ApiException(e));
+            }
+        }
+
+        public void ParseResponse<T>(HttpResponse httpResponse, Action<T> onSuccess, Action<ApiException> onError)
+            where T : new()
+        {
+            if (httpResponse.Error != null && String.IsNullOrEmpty(httpResponse.Body))
+                onError(new ApiException("Error retrieving url", null, httpResponse.Error, httpResponse.Url));
+
+            var response = Protocol.GetResponse<T>(httpResponse.Body);
+            if (response.Error != null)
+                onError(new ApiException(response.Error));
+
+            onSuccess(response.Data);
+        }
+
+        public void GetResponse(string method, string[] urlArguments, Action<HttpResponse> onSuccess, Action<ApiException> onError)
+        {
+            Uri url = UrlHelper.BuildUrl(method, "", BaseUrl, urlArguments, null);
+            WebClient.MakeRequest(url, onSuccess, onError);
+        }
+
+        #endregion
+
+        public void GetSites(Action<IEnumerable<Site>> onSuccess, Action<ApiException> onError = null)
+        {
+            MakeRequest<SitesResponse>("sites", null, response => onSuccess(response.Sites), onError);
+        }
+
+        public void GetAssociatedUsers(Guid associationId, Action<IEnumerable<AssociatedUser>> onSuccess, Action<ApiException> onError = null)
+        {
+            MakeRequest<AssociatedUsersResponse>("users", new string[] { associationId.ToString(), "associated" }, response => onSuccess(response.Users), onError);
+        }
+    }
+}

File trunk/source/Stacky.WindowsPhone/Stacky.WindowsPhone.csproj

View file
     <Compile Include="..\Stacky\Entities\Answer.cs">
       <Link>Entities\Answer.cs</Link>
     </Compile>
+    <Compile Include="..\Stacky\Entities\AssociatedUser.cs">
+      <Link>Entities\AssociatedUser.cs</Link>
+    </Compile>
     <Compile Include="..\Stacky\Entities\Badge.cs">
       <Link>Entities\Badge.cs</Link>
     </Compile>
     <Compile Include="..\Stacky\Enums\SearchSort.cs">
       <Link>Enums\SearchSort.cs</Link>
     </Compile>
+    <Compile Include="..\Stacky\Enums\SiteState.cs">
+      <Link>Enums\SiteState.cs</Link>
+    </Compile>
     <Compile Include="..\Stacky\Enums\SortArgsAttribute.cs">
       <Link>Enums\SortArgsAttribute.cs</Link>
     </Compile>
     <Compile Include="..\Stacky\Responses\AnswerResponse.cs">
       <Link>Responses\AnswerResponse.cs</Link>
     </Compile>
+    <Compile Include="..\Stacky\Responses\AssociatedUsersResponse.cs">
+      <Link>Responses\AssociatedUsersResponse.cs</Link>
+    </Compile>
     <Compile Include="..\Stacky\Responses\BadgeResponse.cs">
       <Link>Responses\BadgeResponse.cs</Link>
     </Compile>
     <Compile Include="..\Stacky\Responses\RevisionResponse.cs">
       <Link>Responses\RevisionResponse.cs</Link>
     </Compile>
+    <Compile Include="..\Stacky\Responses\SitesResponse.cs">
+      <Link>Responses\SitesResponse.cs</Link>
+    </Compile>
     <Compile Include="..\Stacky\Responses\StatsResponse.cs">
       <Link>Responses\StatsResponse.cs</Link>
     </Compile>
       <Link>UrlClientAsync.cs</Link>
     </Compile>
     <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="StackAuthClientAsync.cs" />
   </ItemGroup>
   <ItemGroup />
   <Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.$(TargetFrameworkProfile).Overrides.targets" />

File trunk/source/Stacky/Entities/AssociatedUser.cs

View file
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Newtonsoft.Json;
+
+namespace Stacky
+{
+    public class AssociatedUser
+    {
+        /// <summary>
+        /// Gets or sets the user id.
+        /// </summary>
+        /// <value>The user id.</value>
+        [JsonProperty("user_id")]
+        public long Id { get; set; }
+
+        /// <summary>
+        /// Gets or sets the <see cref="UserType"/>.
+        /// </summary>
+        /// <value>The <see cref="UserType"/>.</value>
+        [JsonProperty("user_type"), JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
+        public UserType Type { get; set; }
+
+        /// <summary>
+        /// Gets or sets the display name.
+        /// </summary>
+        /// <value>The display name.</value>
+        [JsonProperty("display_name")]
+        public string DisplayName { get; set; }
+
+        /// <summary>
+        /// Gets or sets the reputation.
+        /// </summary>
+        /// <value>The reputation.</value>
+        [JsonProperty("reputation")]
+        public int Reputation { get; set; }
+
+        /// <summary>
+        /// Gets or sets the email hash.
+        /// </summary>
+        /// <value>The email hash.</value>
+        [JsonProperty("email_hash")]
+        public string EmailHash { get; set; }
+
+        /// <summary>
+        /// Gets the gravatar URL.
+        /// </summary>
+        /// <value>The gravatar URL.</value>
+        public string GravatarUrl { get { return String.Format("http://www.gravatar.com/avatar/{0}?d=identicon&r=PG", EmailHash); } }
+
+        [JsonProperty("on_site")]
+        public Site Site { get; set; }
+    }
+}

File trunk/source/Stacky/Entities/Site.cs

View file
 
         [JsonProperty("icon_url")]
         public string IconUrl { get; set; }
+
+        [JsonProperty("state"), JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
+        public SiteState State { get; set; }
+
+        [JsonProperty("aliases")]
+        public string[] Aliases { get; set; }
     }
 }

File trunk/source/Stacky/Entities/User.cs

View file
         public BadgeCounts BadgeCounts { get; set; }
 
         /// <summary>
+        /// Gets or sets a global <see cref="System.Guid"/> which identifies
+        /// this user across stack app sites.
+        /// </summary>
+        [JsonProperty("association_id")]
+        public Guid AssociationId { get; set; }
+
+        /// <summary>
         /// Gets or sets the questions URL.
         /// </summary>
         /// <value>The questions URL.</value>

File trunk/source/Stacky/Enums/PostEventType.cs

View file
         /// <summary>
         /// Votes.
         /// </summary>
-        Votes
+        Votes,
+        /// <summary>
+        /// State
+        /// </summary>
+        State,
+        /// <summary>
+        /// Accepted
+        /// </summary>
+        Accepted,
+        /// <summary>
+        /// Unaccepted
+        /// </summary>
+        Unaccepted
     }
 }

File trunk/source/Stacky/Enums/SiteState.cs

View file
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Stacky
+{
+    public enum SiteState
+    {
+        Normal,
+        ClosedBeta,
+        OpenBeta,
+        LinkedMeta
+    }
+}

File trunk/source/Stacky/Helpers/UrlHelper.cs

View file
         {
             Require.NotNullOrEmpty(method, "method");
             Require.NotNullOrEmpty(serviceUrl, "serviceUrl");
-            Require.NotNullOrEmpty(version, "version");
 
             string urlBase = String.Format(CultureInfo.CurrentCulture, "{0}{1}/{2}/", serviceUrl, version, method);
             if (urlParameters != null)

File trunk/source/Stacky/Responses/AssociatedUsersResponse.cs

View file
+using System.Collections.Generic;
+using Newtonsoft.Json;
+
+namespace Stacky
+{
+    public class AssociatedUsersResponse
+    {
+        [JsonProperty("associated_users")]
+        public List<AssociatedUser> Users { get; set; }
+    }
+}

File trunk/source/Stacky/Responses/SitesResponse.cs

View file
+using System.Collections.Generic;
+using Newtonsoft.Json;
+
+namespace Stacky
+{
+    public class SitesResponse
+    {
+        [JsonProperty("api_sites")]
+        public List<Site> Sites { get; set; }
+    }
+}

File trunk/source/Stacky/StackAuthClient.cs

View file
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Stacky
+{
+    public class StackAuthClient
+    {
+        public StackAuthClient(IUrlClient client, IProtocol protocol)
+        {
+            BaseUrl = "http://stackauth.com";
+            WebClient = client;
+            Protocol = protocol;
+        }
+
+        public IUrlClient WebClient { get; set; }
+        public IProtocol Protocol { get; set; }
+        public string BaseUrl { get; private set; }
+
+        #region Methods
+       
+        public T MakeRequest<T>(string method, string[] urlArguments)
+             where T : new()
+        {
+            var httpResponse = GetResponse(method, urlArguments, null);
+            return ParseResponse<T>(httpResponse);
+        }
+
+        public T ParseResponse<T>(HttpResponse httpResponse)
+            where T : new()
+        {
+            if (httpResponse.Error != null && String.IsNullOrEmpty(httpResponse.Body))
+                throw new ApiException("Error retrieving url", null, httpResponse.Error, httpResponse.Url);
+
+            var response = Protocol.GetResponse<T>(httpResponse.Body);
+            if (response.Error != null)
+                throw new ApiException(response.Error);
+
+            return response.Data;
+        }
+
+        public HttpResponse GetResponse(string method, string[] urlArguments, Dictionary<string, string> queryStringArguments)
+        {
+            Uri url = UrlHelper.BuildUrl(method, "", BaseUrl, urlArguments, queryStringArguments);
+            return WebClient.MakeRequest(url);
+        }
+
+        #endregion
+
+        public IEnumerable<Site> GetSites()
+        {
+            return MakeRequest<SitesResponse>("sites", null).Sites;
+        }
+
+        public IEnumerable<AssociatedUser> GetAssociatedUsers(Guid associationId)
+        {
+            return MakeRequest<AssociatedUsersResponse>("users", new string[] { associationId.ToString(), "associated" }).Users;
+        }
+    }
+}

File trunk/source/Stacky/StackAuthClientAsync.cs

View file
+using System;
+using System.Collections.Generic;
+
+namespace Stacky
+{
+#if SILVERLIGHT
+    public class StackAuthClient
+#else
+    public class StackAuthClientAsync
+#endif
+    {
+#if SILVERLIGHT
+		    public StackAuthClient(IUrlClient client, IProtocol protocol)
+#else
+        public StackAuthClientAsync(IUrlClientAsync client, IProtocol protocol)
+#endif
+        {
+            BaseUrl = "http://stackauth.com";
+            WebClient = client;
+            Protocol = protocol;
+        }
+
+#if SILVERLIGHT
+		    public IUrlClient WebClient { get; set; }
+#else
+        public IUrlClientAsync WebClient { get; set; }
+#endif
+        public IProtocol Protocol { get; set; }
+        public string BaseUrl { get; private set; }
+
+        #region Methods
+
+        public void MakeRequest<T>(string method, string[] urlArguments, Action<T> onSuccess, Action<ApiException> onError)
+                where T : new()
+        {
+            try
+            {
+                HttpResponse httpResponse = null;
+                GetResponse(method, urlArguments, response =>
+                {
+                    httpResponse = response;
+                    ParseResponse<T>(httpResponse, onSuccess, onError);
+                }, onError);
+            }
+            catch (Exception e)
+            {
+                onError(new ApiException(e));
+            }
+        }
+
+        public void ParseResponse<T>(HttpResponse httpResponse, Action<T> onSuccess, Action<ApiException> onError)
+            where T : new()
+        {
+            if (httpResponse.Error != null && String.IsNullOrEmpty(httpResponse.Body))
+                onError(new ApiException("Error retrieving url", null, httpResponse.Error, httpResponse.Url));
+
+            var response = Protocol.GetResponse<T>(httpResponse.Body);
+            if (response.Error != null)
+                onError(new ApiException(response.Error));
+
+            onSuccess(response.Data);
+        }
+
+        public void GetResponse(string method, string[] urlArguments, Action<HttpResponse> onSuccess, Action<ApiException> onError)
+        {
+            Uri url = UrlHelper.BuildUrl(method, "", BaseUrl, urlArguments, null);
+            WebClient.MakeRequest(url, onSuccess, onError);
+        }
+
+        #endregion
+
+        public void GetSites(Action<IEnumerable<Site>> onSuccess, Action<ApiException> onError)
+        {
+            MakeRequest<SitesResponse>("sites", null, response => onSuccess(response.Sites), onError);
+        }
+
+        public void GetAssociatedUsers(Guid associationId, Action<IEnumerable<AssociatedUser>> onSuccess, Action<ApiException> onError)
+        {
+            MakeRequest<AssociatedUsersResponse>("users", new string[] { associationId.ToString(), "associated" }, response => onSuccess(response.Users), onError);
+        }
+    }
+}

File trunk/source/Stacky/Stacky.csproj

View file
   <ItemGroup>
     <Compile Include="ApiException.cs" />
     <Compile Include="Entities\Answer.cs" />
+    <Compile Include="Entities\AssociatedUser.cs" />
     <Compile Include="Entities\Badge.cs" />
     <Compile Include="Entities\BadgeCounts.cs" />
     <Compile Include="Entities\Comment.cs" />
     <Compile Include="Enums\QuestionsByUserSort.cs" />
     <Compile Include="Enums\QuestionSort.cs" />
     <Compile Include="Enums\SearchSort.cs" />
+    <Compile Include="Enums\SiteState.cs" />
     <Compile Include="Enums\SortDirection.cs" />
     <Compile Include="Enums\TagSort.cs" />
     <Compile Include="Enums\UserEventType.cs" />
     <Compile Include="Protocols\JsonProtocol.cs" />
     <Compile Include="Protocols\JsonResponse.cs" />
     <Compile Include="Responses\AnswerResponse.cs" />
+    <Compile Include="Responses\AssociatedUsersResponse.cs" />
     <Compile Include="Responses\BadgeResponse.cs" />
     <Compile Include="Responses\CommentResponse.cs" />
     <Compile Include="Responses\ErrorResponse.cs" />
     <Compile Include="Responses\ReputationResponse.cs" />
     <Compile Include="Responses\Response.cs" />
     <Compile Include="Responses\RevisionResponse.cs" />
+    <Compile Include="Responses\SitesResponse.cs" />
     <Compile Include="Responses\StatsResponse.cs" />
     <Compile Include="Responses\TagResponse.cs" />
     <Compile Include="Responses\UserEventResponse.cs" />
     <Compile Include="Responses\UserResponse.cs" />
     <Compile Include="Sites.cs" />
+    <Compile Include="StackAuthClient.cs" />
+    <Compile Include="StackAuthClientAsync.cs" />
     <Compile Include="StackyClientAsync\AnswerMethods.cs" />
     <Compile Include="StackyClientAsync\BadgeMethods.cs" />
     <Compile Include="StackyClientAsync\CommentMethods.cs" />

File trunk/source/Tests/Stacky.IntegrationTests/HostSiteTests.cs

View file
 namespace Stacky.IntegrationTests
 {
     [TestClass]
-    public class HostSiteTests
+    public class HostSiteTests : IntegrationTest
     {
         private StackyClient GetClient(Site site)
         {
             var questions = client.GetQuestions();
             Assert.IsNotNull(questions);
         }
+
+        [TestMethod]
+        public void GetSites()
+        {
+            var sites = AuthClient.GetSites();
+            Assert.IsNotNull(sites);
+        }
+
+        [TestMethod]
+        public void GetAssociatedUsers()
+        {
+            var users = AuthClient.GetAssociatedUsers(new Guid("05121a2b-3289-4965-a5f4-f26affeadc63"));
+            Assert.IsNotNull(users);
+        }
     }
 }

File trunk/source/Tests/Stacky.IntegrationTests/IntegrationTest.cs

View file
         {
             Client = new StackyClient(Version, ApiKey, Sites.StackOverflow, new UrlClient(), new JsonProtocol());
             ClientAsync = new StackyClientAsync(Version, ApiKey, Sites.StackOverflow.ApiEndpoint, new UrlClientAsync(), new JsonProtocol());
+            AuthClient = new StackAuthClient(new UrlClient(), new JsonProtocol());
         }
 
         public StackyClient Client { get; set; }
         public StackyClientAsync ClientAsync { get; set; }
+        public StackAuthClient AuthClient { get; set; }
     }
 }

File trunk/source/Tests/Stacky.IntegrationTests/UserTests.cs

View file
             var users = Client.GetModerators();
             Assert.IsNotNull(users);
         }
+
+        [TestMethod]
+        public void UserHasAssociationId()
+        {
+            var user = Client.GetUser(646);
+            Assert.IsNotNull(user);
+
+            Assert.IsNotNull(user.AssociationId);
+            Assert.IsFalse(user.AssociationId == Guid.Empty);
+        }
     }
 }

File trunk/source/Tests/Stacky.Net35.IntegrationTests/HostSiteTests.cs

View file
 namespace Stacky.IntegrationTests.Net35
 {
     [TestClass]
-    public class HostSiteTests
+    public class HostSiteTests : IntegrationTest
     {
         private StackyClient GetClient(Site site)
         {
             Assert.IsNotNull(stats.Site);
             Assert.AreEqual("Stack Apps", stats.Site.Name);
         }
+
+        [TestMethod]
+        public void GetSites()
+        {
+            var sites = AuthClient.GetSites();
+            Assert.IsNotNull(sites);
+        }
+
+        [TestMethod]
+        public void GetAssociatedUsers()
+        {
+            var users = AuthClient.GetAssociatedUsers(new Guid("05121a2b-3289-4965-a5f4-f26affeadc63"));
+            Assert.IsNotNull(users);
+        }
     }
 }

File trunk/source/Tests/Stacky.Silverlight.IntegrationTests/HostSiteTests.cs

View file
 namespace Stacky.Silverlight.IntegrationTests
 {
     [TestClass]
-    public class HostSiteTests : SilverlightTest
+    public class HostSiteTests : IntegrationTest
     {
         private StackyClient GetClient(Site site)
         {
             var client = GetClient(Sites.StackApps);
             TestQuestionMethod(client);
         }
+
+        [TestMethod, Asynchronous]
+        public void GetSites()
+        {
+            using (var context = new AsynchronusTestContext(this))
+            {
+                IEnumerable<Site> received = null;
+                ApiException exception = null;
+
+                bool completed = false;
+                EnqueueCallback(() =>
+                {
+                    AuthClient.GetSites(results =>
+                    {
+                        received = results;
+                        completed = true;
+                    },
+                    error =>
+                    {
+                        exception = error;
+                        completed = true;
+                    });
+                });
+                EnqueueConditional(() => completed);
+                EnqueueCallback(() => Assert.IsNull(exception));
+                EnqueueCallback(() => Assert.IsNotNull(received));
+            }
+        }
+
+        [TestMethod, Asynchronous]
+        public void GetAssociatedUsers()
+        {
+            using (var context = new AsynchronusTestContext(this))
+            {
+                IEnumerable<AssociatedUser> received = null;
+                ApiException exception = null;
+
+                bool completed = false;
+                EnqueueCallback(() =>
+                {
+                    AuthClient.GetAssociatedUsers(new Guid("05121a2b-3289-4965-a5f4-f26affeadc63"), results =>
+                    {
+                        received = results;
+                        completed = true;
+                    },
+                    error =>
+                    {
+                        exception = error;
+                        completed = true;
+                    });
+                });
+                EnqueueConditional(() => completed);
+                EnqueueCallback(() => Assert.IsNull(exception));
+                EnqueueCallback(() => Assert.IsNotNull(received));
+            }
+        }
     }
 }

File trunk/source/Tests/Stacky.Silverlight.IntegrationTests/IntegrationTest.cs

View file
         protected static IProtocol protocol = new JsonProtocol();
 
         protected StackyClient Client { get; private set; }
+        protected StackAuthClient AuthClient { get; private set; }
 
         public IntegrationTest()
         {
             Client = new StackyClient(Version, ApiKey, hostSite, urlClient, protocol);
+            AuthClient = new StackAuthClient(urlClient, protocol);
         }
     }
 }