Example #1
0
        public async Task UpdateProfileBanner_ReturnsFromQueryExecutor()
        {
            // Arrange
            var controller    = CreateAccountSettingsController();
            var parameters    = new UpdateProfileBannerParameters(null);
            var request       = A.Fake <ITwitterRequest>();
            var twitterResult = A.Fake <ITwitterResult>();

            A.CallTo(() => _fakeAccountSettingsQueryExecutor.UpdateProfileBanner(parameters, request)).Returns(twitterResult);

            // Act
            var result = await controller.UpdateProfileBanner(parameters, request);

            // Assert
            Assert.Equal(result, twitterResult);
        }
        public void GetUpdateProfileBannerQuery_ReturnsExpectedQuery()
        {
            // arrange
            var queryGenerator = CreateAccountSettingsQueryGenerator();
            var parameters     = new UpdateProfileBannerParameters(null)
            {
                Height                = 42,
                Width                 = 43,
                OffsetLeft            = 44,
                OffsetTop             = 45,
                CustomQueryParameters = { new Tuple <string, string>("hello", "world") }
            };

            // act
            var result = queryGenerator.GetUpdateProfileBannerQuery(parameters);

            // assert
            Assert.Equal(result, $"https://api.twitter.com/1.1/account/update_profile_banner.json?width=43&height=42&offset_left=44&offset_top=45&hello=world");
        }
        public async Task UpdateProfileBanner_ReturnsAccountUserDTOAsync()
        {
            // Arrange
            var queryExecutor = CreateAccountSettingsQueryExecutor();
            var parameters    = new UpdateProfileBannerParameters(new byte[2]);

            var url            = TestHelper.GenerateString();
            var request        = A.Fake <ITwitterRequest>();
            var expectedResult = A.Fake <ITwitterResult>();

            A.CallTo(() => _fakeAccountSettingsQueryGenerator.GetUpdateProfileBannerQuery(parameters)).Returns(url);
            A.CallTo(() => _fakeTwitterAccessor.ExecuteRequestAsync(A <ITwitterRequest> .Ignored)).Returns(expectedResult);

            // Act
            var result = await queryExecutor.UpdateProfileBannerAsync(parameters, request);

            // Assert
            Assert.Equal(result, expectedResult);
            Assert.True(request.Query.IsHttpContentPartOfQueryParams);
            Assert.Equal(request.Query.Url, url);
            Assert.Equal(HttpMethod.POST, request.Query.HttpMethod);
        }