Beispiel #1
0
        public void GetUnblockUserQuery_WithValidUserDTO_ReturnsExpectedQuery()
        {
            // Arrange
            var queryGenerator = CreateUserQueryGenerator();
            var user           = new UserIdentifier(42);

            var parameters = new UnblockUserParameters(user)
            {
                CustomQueryParameters = { new Tuple <string, string>("hello", "world") }
            };

            // Act
            var result = queryGenerator.GetUnblockUserQuery(parameters);

            // Assert
            Assert.Equal(result, $"https://api.twitter.com/1.1/blocks/destroy.json?user_id=42&hello=world");
        }
Beispiel #2
0
        public async Task UnblockUser_ReturnsFromUserQueryExecutor()
        {
            // Arrange
            var controller = CreateUserController();
            var userDTO    = A.Fake <IUserDTO>();

            var parameters     = new UnblockUserParameters(userDTO);
            var request        = A.Fake <ITwitterRequest>();
            var expectedResult = A.Fake <ITwitterResult <IUserDTO> >();

            A.CallTo(() => _fakeUserQueryExecutor.UnblockUser(parameters, request)).Returns(expectedResult);

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

            // Assert
            Assert.Equal(result, expectedResult);
        }
Beispiel #3
0
        public async Task UnblockUser_ReturnsUserDTOAsync()
        {
            // Arrange
            var queryExecutor = CreateUserQueryExecutor();
            var userDTO       = A.Fake <IUserDTO>();

            var url            = TestHelper.GenerateString();
            var parameters     = new UnblockUserParameters(userDTO);
            var request        = A.Fake <ITwitterRequest>();
            var expectedResult = A.Fake <ITwitterResult <IUserDTO> >();

            A.CallTo(() => _fakeUserQueryGenerator.GetUnblockUserQuery(parameters)).Returns(url);
            A.CallTo(() => _fakeTwitterAccessor.ExecuteRequestAsync <IUserDTO>(request)).Returns(expectedResult);

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

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