public void Set_FoundBeerIsDeletedPropertyToTrue() { var id = this.Fixture.Create <int>(); var expected = new Beer() { IsDeleted = false }; var repository = new Mock <IRepository <Brewery> >(); var beerRepo = new Mock <IRepository <Beer> >(); beerRepo.Setup(r => r.GetById(id)) .Returns(expected); var service = new BreweryService(repository.Object, beerRepo.Object); service.DeleteBeer(id); Assert.IsTrue(expected.IsDeleted); }
public void ReturnResultFromRepositorySaveChangesMethod() { var id = this.Fixture.Create <int>(); var beer = new Beer(); var expected = new Mock <IDataModifiedResult>(); var repository = new Mock <IRepository <Brewery> >(); var beerRepo = new Mock <IRepository <Beer> >(); beerRepo.Setup(r => r.GetById(id)) .Returns(beer); beerRepo.Setup(r => r.SaveChanges()) .Returns(expected.Object); var service = new BreweryService(repository.Object, beerRepo.Object); var result = service.DeleteBeer(id); Assert.AreSame(expected.Object, result); }
public void Call_BeerRepositoryGetByIdMethodOnceWithCorrectParams() { var id = this.Fixture.Create <int>(); var expected = new Beer() { IsDeleted = false }; var repository = new Mock <IRepository <Brewery> >(); var beerRepo = new Mock <IRepository <Beer> >(); beerRepo.Setup(r => r.GetById(id)) .Returns(expected); var service = new BreweryService(repository.Object, beerRepo.Object); service.DeleteBeer(id); beerRepo.Verify(r => r.GetById(id), Times.Once); }