コード例 #1
0
        public async void should_return_emptylist_if_query_string_isempty()
        {
            //Act
            var sut = new SearchServiceBuilder().WithWordRepository(_wordRepository.Object)
                                                .Build();

            var result = await sut.Query(string.Empty);

            //Assert
            Assert.IsEmpty(result);
        }
コード例 #2
0
        public async void should_return_searchresult_with_substringed_exp()
        {
            //arrange 
            const int expMaxlength = 15;

            //act
            var sut = new SearchServiceBuilder().WithWordRepository(_wordRepository.Object)
                                                .Build();

            var result = await sut.Query("k1 k2");

            //assert
            Assert.AreEqual(1, result.Count);

            var searchResult = result.First();
            Assert.AreEqual(string.Format(_name, "k1_k2", _exp.Substring(0, expMaxlength)), searchResult.Name);
        }
コード例 #3
0
        public async void should_return_one_custom_searchresult()
        {
            //act
            var sut = new SearchServiceBuilder().WithWordRepository(_wordRepository.Object)
                                                .Build();

            var result = await sut.Query("k1_k3");

            //assert
            Assert.AreEqual(1, result.Count);

            var searchResult = result.First();

            Assert.IsNotNull(searchResult);

            Assert.AreEqual(string.Format(_wordDetail, "k1_k3"), searchResult.Url);
            Assert.AreEqual(string.Format(_name, "k1_k3", "eng3"), searchResult.Name);
            Assert.AreEqual(_imgUrl, searchResult.ImgUrl);
        }
コード例 #4
0
        public async void should_return_results_in_descending_order()
        {
            //act
            var sut = new SearchServiceBuilder().WithWordRepository(_wordRepository.Object)
                                                .Build();

            var result = await sut.Query("k1");

            //assert
            Assert.AreEqual(3, result.Count);

            var firstResult = result.First();
            Assert.AreEqual(string.Format(_wordDetail, "k1_k3"), firstResult.Url);

            var lastResult = result.Last();
            Assert.AreEqual(string.Format(_wordDetail, "k1"), lastResult.Url);
        }