예제 #1
0
        public async Task GetRelationshipBetween_ReturnsFromUserQueryExecutor()
        {
            // Arrange
            var controller     = CreateUserController();
            var parameters     = new GetRelationshipBetweenParameters(42, 43);
            var request        = A.Fake <ITwitterRequest>();
            var expectedResult = A.Fake <ITwitterResult <IRelationshipDetailsDTO> >();

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

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

            // Assert
            Assert.Equal(result, expectedResult);
        }
예제 #2
0
        public void GetRelationshipBetween_ReturnsExpectedQuery()
        {
            // Arrange
            var parameters = new GetRelationshipBetweenParameters(42, 43)
            {
                CustomQueryParameters = { new Tuple <string, string>("hello", "world") }
            };

            var queryGenerator = CreateUserQueryGenerator();

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

            // Assert
            Assert.Equal(result, $"https://api.twitter.com/1.1/friendships/show.json?source_id=42&target_id=43&hello=world");
        }
예제 #3
0
        public async Task GetRelationshipBetween_ReturnsRelationshipDTOAsync()
        {
            // Arrange
            var queryExecutor  = CreateUserQueryExecutor();
            var request        = A.Fake <ITwitterRequest>();
            var url            = TestHelper.GenerateString();
            var parameter      = new GetRelationshipBetweenParameters(42, 43);
            var expectedResult = A.Fake <ITwitterResult <IRelationshipDetailsDTO> >();

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

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

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