コード例 #1
0
        public void Test_GetUserAvatar_HttpRequest()
        {
            var request     = new UserAvatarRequest(FakeToken, "*****@*****.**", 112);
            var httpRequest = TestConnection.CreateHttpRequestMessage(DummyServerUri, request);

            Assert.AreEqual(HttpMethod.Get, httpRequest.Method);
            Assert.AreEqual(DummyServerUri + "api2/avatars/user/[email protected]/resized/112/", httpRequest.RequestUri.ToString());
        }
コード例 #2
0
        public void Test_GetUserAvatar_Success()
        {
            var request = new UserAvatarRequest(FakeToken, "*****@*****.**", 112);

            var message = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(@"{
                        ""url"": ""http://127.0.0.1:8000/media/avatars/default.png"",
                        ""is_default"": true,
                        ""mtime"": 1311012500}")
            };

            Assert.IsTrue(request.WasSuccessful(message));
            var result = ExecuteSync(() => request.ParseResponseAsync(message));

            Assert.AreEqual("http://127.0.0.1:8000/media/avatars/default.png", result.Url);
            Assert.IsTrue(result.IsDefault);
            Assert.AreEqual(DateTime.Parse("Mon, 18 Jul 2011 18:08:20 GMT", CultureInfo.InvariantCulture), result.Timestamp);
        }
コード例 #3
0
        /// <summary>
        ///     Retrieve the avatar of the given user
        /// </summary>
        /// <param name="username">The username to retrieve the avatar for</param>
        /// <param name="size">Size of the requested image in pixels (width=height)</param>
        public async Task <UserAvatar> GetUserAvatar(string username, int size)
        {
            var request = new UserAvatarRequest(AuthToken, username, size);

            return(await _webConnection.SendRequestAsync(ServerUri, request));
        }