public void NotebookService_Should_Get_Content_When_Call_GetContent(string text) { var mockedRepository = new Mock <INotebooksRepository>(); mockedRepository.Setup(r => r.Find(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())) .Returns( new Notebook() { Id = 0, Content = text, Subject = text, Type = text, Username = text }); var mockedUnitOfWork = new Mock <IUnitOfWork>(); mockedUnitOfWork.Setup(u => u.Commit()); var mockedDbContext = new Mock <INotebookDbContext>(); var service = new NotebookService(mockedRepository.Object, mockedUnitOfWork.Object, new MockedDbContext()); service.Initialize(); Assert.AreEqual(text, service.GetContent()); }
public void NotebookService_Should_Throw_When_Try_To_Get_Content_Before_Initialization() { var mockedRepository = new Mock <INotebooksRepository>(); var mockedUnitOfWork = new Mock <IUnitOfWork>(); var mockedDbContext = new Mock <INotebookDbContext>(); var service = new NotebookService(mockedRepository.Object, mockedUnitOfWork.Object, new MockedDbContext()); Assert.Throws <NullReferenceException>(() => service.GetContent()); }