public void SearchTweet_FilterOriginal_FilterTheResults() { // Arrange var queryExecutor = CreateSearchQueryExecutor(); var searchParameter = A.Fake <ITweetSearchParameters>(); searchParameter.CallsTo(x => x.SearchQuery).Returns(_searchQuery); searchParameter.CallsTo(x => x.TweetSearchType).Returns(TweetSearchType.OriginalTweetsOnly); var matchingTweetDTOs = new[] { _originalTweetDTO, _retweetDTO }; _searchResultDTO.CallsTo(x => x.TweetDTOs).Returns(matchingTweetDTOs); _fakeSearchQueryGenerator.CallsTo(x => x.GetSearchTweetsQuery(searchParameter)).Returns(_httpQuery); _fakeTwitterAccessor.ArrangeExecuteGETQuery(_httpQuery, _searchResultDTO); // Act var result = queryExecutor.SearchTweets(searchParameter); // Assert Assert.IsTrue(result.Contains(_originalTweetDTO)); Assert.IsFalse(result.Contains(_retweetDTO)); }
public void TestInitialize() { _fakeBuilder = new FakeClassBuilder<SearchQueryExecutor>(); _fakeSearchQueryGenerator = _fakeBuilder.GetFake<ISearchQueryGenerator>(); _fakeSearchQueryHelper = _fakeBuilder.GetFake<ISearchQueryHelper>(); _fakeTwitterAccessor = _fakeBuilder.GetFake<ITwitterAccessor>(); _fakeTweetHelper = _fakeBuilder.GetFake<ITweetHelper>(); _fakeSearchQueryParameterGenerator = _fakeBuilder.GetFake<ISearchQueryParameterGenerator>(); _searchQuery = TestHelper.GenerateString(); _httpQuery = TestHelper.GenerateString(); _statusesJson = TestHelper.GenerateString(); _originalTweetDTO = GenerateTweetDTO(true); _retweetDTO = GenerateTweetDTO(false); _jObject = new JObject(); _jObject["statuses"] = _statusesJson; _tweetDTOs = new[] { A.Fake<ITweetWithSearchMetadataDTO>() }; _searchResultDTO = A.Fake<ISearchResultsDTO>(); _searchResultDTO.CallsTo(x => x.TweetDTOs).Returns(_tweetDTOs); _tweetSearchParameter = A.Fake<ITweetSearchParameters>(); _fakeSearchQueryParameterGenerator.CallsTo(x => x.CreateSearchTweetParameter(_searchQuery)).Returns(_tweetSearchParameter); }
public void TestInitialize() { _fakeBuilder = new FakeClassBuilder <SearchQueryExecutor>(); _fakeSearchQueryGenerator = _fakeBuilder.GetFake <ISearchQueryGenerator>(); _fakeSearchQueryHelper = _fakeBuilder.GetFake <ISearchQueryHelper>(); _fakeTwitterAccessor = _fakeBuilder.GetFake <ITwitterAccessor>(); _fakeTweetHelper = _fakeBuilder.GetFake <ITweetHelper>(); _fakeSearchQueryParameterGenerator = _fakeBuilder.GetFake <ISearchQueryParameterGenerator>(); _searchQuery = TestHelper.GenerateString(); _httpQuery = TestHelper.GenerateString(); _statusesJson = TestHelper.GenerateString(); _originalTweetDTO = GenerateTweetDTO(true); _retweetDTO = GenerateTweetDTO(false); _jObject = new JObject(); _jObject["statuses"] = _statusesJson; _tweetDTOs = new[] { A.Fake <ITweetWithSearchMetadataDTO>() }; _searchResultDTO = A.Fake <ISearchResultsDTO>(); _searchResultDTO.CallsTo(x => x.TweetDTOs).Returns(_tweetDTOs); _tweetSearchParameter = A.Fake <ITweetSearchParameters>(); _fakeSearchQueryParameterGenerator.CallsTo(x => x.CreateSearchTweetParameter(_searchQuery)).Returns(_tweetSearchParameter); }