コード例 #1
0
        public async Task GetUser_ReturnsFromUserQueryExecutor()
        {
            // Arrange
            var controller = CreateUserController();

            var parameters     = new GetUserParameters("username");
            var expectedResult = A.Fake <ITwitterResult <IUserDTO> >();

            A.CallTo(() => _fakeUserQueryExecutor.GetUser(parameters, A <ITwitterRequest> .Ignored)).Returns(expectedResult);

            // Act
            var twitterResultUser = await controller.GetUser(parameters, A.Fake <ITwitterRequest>());

            // Assert
            Assert.Same(twitterResultUser, expectedResult);
        }
コード例 #2
0
        public void GetUserQuery_ReturnsExpectedQuery()
        {
            // Arrange
            var parameters = new GetUserParameters(42)
            {
                SkipStatus            = true,
                IncludeEntities       = true,
                CustomQueryParameters = { new Tuple <string, string>("hello", "world") }
            };

            var queryGenerator = CreateUserQueryGenerator();

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

            // Assert
            Assert.Equal(result, $"https://api.twitter.com/1.1/users/show.json?user_id=42&skip_status=true&include_entities=true&hello=world");
        }
コード例 #3
0
        public async Task GetUser_ReturnsUserDTOAsync()
        {
            // Arrange
            var queryExecutor  = CreateUserQueryExecutor();
            var request        = A.Fake <ITwitterRequest>();
            var url            = TestHelper.GenerateString();
            var parameter      = new GetUserParameters(42);
            var expectedResult = A.Fake <ITwitterResult <IUserDTO> >();

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

            // Act
            var result = await queryExecutor.GetUserAsync(parameter, request);

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