public void ThrowException_WhenNullPageContent() { //Arrange var mockedRepository = new Mock <IEFRepository <PageContent> >(); var mockedUnitOfWork = new Mock <IUnitOfWork>(); var pageContentService = new PageContentService(mockedRepository.Object, mockedUnitOfWork.Object); //Act Mock <PageContent> content = null; //Assert Assert.Throws <NullReferenceException>(() => pageContentService.FindBySectionName(content.Object.SectionName)); }
public void ReturnNull_WhenNoPageContentFound(string testSectionName) { //Arrange var mockedRepository = new Mock <IEFRepository <PageContent> >(); var mockedUnitOfWork = new Mock <IUnitOfWork>(); var pageContentService = new PageContentService(mockedRepository.Object, mockedUnitOfWork.Object); //Act mockedRepository.Setup(repository => repository.GetFirst(x => x.SectionName == testSectionName)) .Returns(() => null); //Assert Assert.IsNull(pageContentService.FindBySectionName(testSectionName)); }