Esempio n. 1
0
        public async Task GetAvatarAsync_WhenCalled_ReturnsBitmapSourceObjectInstance()
        {
            var response = new HttpResponseMessage(HttpStatusCode.OK);

            response.Content = new ByteArrayContent(ImageExtensions.CreateRandomBitmap().ToArray());

            _requestsWrapper
            .SetupSequence(rw => rw.GetAsyncWrapper(It.IsAny <string>()))
            .Returns(Task.FromResult(response));

            var result = await _amSpaceClient.GetAvatarAsync("a");

            Assert.IsInstanceOf <BitmapSource>(result);
        }
Esempio n. 2
0
        public void GetAvatarAsync_WhenCalledNotFromProductionEnvironment_ReturnsDefaultAvatar()
        {
            var response1 = new HttpResponseMessage(HttpStatusCode.Unauthorized);

            response1.Content = new StringContent("a");
            var response2 = new HttpResponseMessage(HttpStatusCode.OK);

            response2.Content = new ByteArrayContent(ImageExtensions.CreateRandomBitmap().ToArray());

            _requestsWrapper
            .SetupSequence(rw => rw.GetAsyncWrapper(It.IsAny <string>()))
            .Returns(Task.FromResult(response1))
            .Returns(Task.FromResult(response2));

            var result = _amSpaceClient.GetAvatarAsync("a");

            _requestsWrapper.Verify(rw => rw.GetAsyncWrapper(It.IsAny <string>()), Times.Exactly(2));
        }