public void ThrowArgumentNullException_WhenStoryDtoIsNull() { //Arrange var storiesRepoMock = new Mock <IEfRepository <Story> >(); var storyStarsRepoMock = new Mock <IEfRepository <StoryStar> >(); var storyService = new Services.StoryService(storiesRepoMock.Object, storyStarsRepoMock.Object); //Act && Assert Assert.Throws <ArgumentNullException>(() => storyService.Update(null)); }
public void NotCallStoryRepoUpdateOnce_WhenStoryIsExistent() { //Arrange var storiesRepoMock = new Mock <IEfRepository <Story> >(); var storyDto = new StoryDto() { Id = Guid.NewGuid() }; var storyStarsRepoMock = new Mock <IEfRepository <StoryStar> >(); var storyService = new Services.StoryService(storiesRepoMock.Object, storyStarsRepoMock.Object); Story storyFromRepo = null; storiesRepoMock.Setup(m => m.GetById(storyDto.Id)).Returns(storyFromRepo); //Act storyService.Update(storyDto); //Assert storiesRepoMock.Verify(m => m.Update(storyFromRepo), Times.Never); }