public async Task UpdatePhraseologyCategory_ReturningTrueAndObject() { _mockUnitOfWork.Setup(x => x.CommitAsync()).ReturnsAsync(true); _mockPhraseologyRepository.Setup(x => x.GetById(It.IsAny <int>())).ReturnsAsync(new Phraseology { Id = 1, Answer = "test phraseologyDto 1", PhraseologyTypeSubject = new PhraseologyTypeSubject { Id = 1, Description = "teste PhraseologyTypeSubject 1" } }); var phraseologyDto = new PhraseologyDto { Answer = "test phraseologyDto 2", PhraseologyTypeSubjectId = 1 }; _mockPhraseologyTypeSubjectRepository.Setup(x => x.GetById(It.IsAny <int>())).ReturnsAsync(new PhraseologyTypeSubject { Id = 1, Description = "teste PhraseologyTypeSubject 2" }); var phraseologyService = new PhraseologyService(_mockPhraseologyRepository.Object, _mockPhraseologyTypeSubjectRepository.Object, _mockUnitOfWork.Object, _mapper); var result = await phraseologyService.UpdatePhraseology(phraseologyDto); Assert.True(result.Updated); Assert.IsType <Phraseology>(result.Phraseology); Assert.Equal("test phraseologyDto 2", result.Phraseology.Answer); Assert.Equal("teste PhraseologyTypeSubject 2", result.Phraseology.PhraseologyTypeSubject.Description); }
public async Task GetAllPhraseologies_ReturningPhraseologyList() { _mockPhraseologyRepository.Setup(x => x.GetAll(It.IsAny <Expression <Func <Phraseology, object> > >())).ReturnsAsync(new List <Phraseology>()); var phraseologyService = new PhraseologyService(_mockPhraseologyRepository.Object, _mockPhraseologyTypeSubjectRepository.Object, _mockUnitOfWork.Object, _mapper); var result = await phraseologyService.GetAllPhraseologies(); Assert.IsType <List <Phraseology> >(result); }
public async Task GetPhraseology_ReturningPhraseology() { _mockPhraseologyRepository.Setup(x => x.CustomFind( It.IsAny <Expression <Func <Phraseology, bool> > >(), It.IsAny <Expression <Func <Phraseology, object> > >(), It.IsAny <Expression <Func <Phraseology, object> > >(), It.IsAny <Expression <Func <Phraseology, object> > >())).ReturnsAsync(new List <Phraseology> { new Phraseology() }); var phraseologyService = new PhraseologyService(_mockPhraseologyRepository.Object, _mockPhraseologyTypeSubjectRepository.Object, _mockUnitOfWork.Object, _mapper); var result = await phraseologyService.GetPhraseology(1); Assert.IsType <Phraseology>(result); }