public async Task GetBySearchText_ShouldReturnEntryBook()
        {
            var entryBook = FakeObjects.FakeObjects.GetListEntryBook();

            _entryBookService.GetDataBySearchText(1, "X").Returns(entryBook.FindAll(x => x.PersonName.Contains("x")));
            var actionResult = await _sut.GetById(1, "X");

            actionResult.Value.Equals(entryBook.FindAll(x => x.PersonName.Contains("x")));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <List <EntryBookDto> > > GetById(int id, string searchText)
        {
            List <EntryBookDto> entries = await _entryBookService.GetDataBySearchText(id, searchText);

            if (entries != null || entries.Count != 0)
            {
                return(entries);
            }
            return(NoContent());
        }
        public async Task GetDataBySearchText_ShouldReturnEntriesStartingWithSearchText()
        {
            var entryBook = FakeObjects.FakeObjects.GetListEntryBook();

            _entryBookRepo.GetDataBySearchText(1, "x").Returns(entryBook);

            var result = await _sut.GetDataBySearchText(1, "x");

            Assert.NotNull(result);
            result[0].Should().Equals(entryBook[0]);
            result.Find(x => x.PersonName.Contains("x").Equals(entryBook[0].PersonName));
        }