public async Task DeleteTutorial_WithInValidiD_ShouldDoNating() { //Arrange var db = this.SetDb(); await this.SeedTutorials(db); var repo = new Repository <Tutorial>(db); var service = new TutorialService(repo, this.Mapper, null); //Act //Asser await Assert.ThrowsAsync <NullReferenceException>(async() => await service.DeleteTutorial(3)); }
public void DeleteTutorialById_Success_Test() { // Arrange int id = 1; // create mock for repository var mock = new Mock <ITutorialRepository>(); mock.Setup(s => s.DeleteTutorial(Moq.It.IsAny <int>())).Verifiable(); // service TutorialService tutorialService = new TutorialService(); TutorialService.Repository = mock.Object; // Act tutorialService.DeleteTutorial(id); // Assert Assert.IsTrue(true); }
public void DeleteTutorial_Success_Test() { // Arrange TutorialDTO dto = SampleTutorialDTO(1); dto.IsDeleted = false; // create mock for repository var mock = new Mock <ITutorialRepository>(); mock.Setup(s => s.DeleteTutorial(Moq.It.IsAny <R_Tutorial>())).Verifiable(); // service TutorialService tutorialService = new TutorialService(); TutorialService.Repository = mock.Object; // Act tutorialService.DeleteTutorial(dto); // Assert Assert.IsTrue(true); }
public async Task DeleteTutorial_WithValidiD_ShouldDeleteTheTutorial() { //Arrange var db = this.SetDb(); await this.SeedTutorials(db); var repo = new Repository <Tutorial>(db); var service = new TutorialService(repo, this.Mapper, null); //Act await service.DeleteTutorial(1); var expectedRepoCount = 1; var actualRepoCount = repo.All().Count(); var expectedTutorialId = 2; var actualTutorialId = repo.All().First().Id; //Asser Assert.Equal(expectedRepoCount, actualRepoCount); Assert.Equal(expectedTutorialId, actualTutorialId); }