public void ShouldGiveBadRequestErrorWhenIdIsNullEdit() { var fakeBeerRepository = new Mock<IRepository<Beer>>(); var fakeBeerTypeRepository = new Mock<IRepository<BeerType>>(); var fakeBreweryRepository = new Mock<IRepository<Brewery>>(); var sut = new BeersController(fakeBeerRepository.Object, fakeBreweryRepository.Object, fakeBeerTypeRepository.Object); sut.WithCallTo(x => x.Edit(null as int?)).ShouldGiveHttpStatus(HttpStatusCode.BadRequest); }
public void ShouldGiveHttpNotFoundWhenBeerIdNotExistsDelete() { var fakeBeerRepository = new Mock<IRepository<Beer>>(); var fakeBeerTypeRepository = new Mock<IRepository<BeerType>>(); var fakeBreweryRepository = new Mock<IRepository<Brewery>>(); var sut = new BeersController(fakeBeerRepository.Object, fakeBreweryRepository.Object, fakeBeerTypeRepository.Object); sut.WithCallTo(x => x.Delete(1)).ShouldGiveHttpStatus(HttpStatusCode.NotFound); }
public void ShouldRenderIndexViewAfterCreatingNewBeer() { var fakeBeerRepository = new Mock<IRepository<Beer>>(); var fakeBeerTypeRepository = new Mock<IRepository<BeerType>>(); var fakeBreweryRepository = new Mock<IRepository<Brewery>>(); var sut = new BeersController(fakeBeerRepository.Object, fakeBreweryRepository.Object, fakeBeerTypeRepository.Object); sut.WithCallTo(x => x.Create(new Beer(), new Mock<HttpPostedFileBase>().Object)).ShouldRedirectToRoute(""); }
public void ShouldRenderIndexView() { var fakeBeerRepository = new Mock<IRepository<Beer>>(); var fakeBeerTypeRepository = new Mock<IRepository<BeerType>>(); var fakeBreweryRepository = new Mock<IRepository<Brewery>>(); var sut = new BeersController(fakeBeerRepository.Object, fakeBreweryRepository.Object, fakeBeerTypeRepository.Object); sut.WithCallTo(x => x.Index(null)).ShouldRenderDefaultView(); }
public void ShouldRenderEditViewWhenBeerHasBeenEdited() { var fakeBeerRepository = new Mock<IRepository<Beer>>(); var fakeBeerTypeRepository = new Mock<IRepository<BeerType>>(); var fakeBreweryRepository = new Mock<IRepository<Brewery>>(); var sut = new BeersController(fakeBeerRepository.Object, fakeBreweryRepository.Object, fakeBeerTypeRepository.Object); fakeBeerRepository.Setup(x => x.GetById(2)).Returns(new Beer()); sut.WithCallTo(x => x.Edit(2)).ShouldRenderDefaultView(); }
public void ShouldRenderDefaultViewWhenInvalidModelState() { var fakeBeerRepository = new Mock<IRepository<Beer>>(); var fakeBeerTypeRepository = new Mock<IRepository<BeerType>>(); var fakeBreweryRepository = new Mock<IRepository<Brewery>>(); var sut = new BeersController(fakeBeerRepository.Object, fakeBreweryRepository.Object, fakeBeerTypeRepository.Object); sut.ModelState.AddModelError("1", "Error"); sut.WithCallTo(x => x.Create(new Beer(), new Mock<HttpPostedFileBase>().Object)).ShouldRenderDefaultView(); }
public void ShouldRenderDefaultViewWhenBeerHasBeenEdited() { var fakeBeerRepository = new Mock<IRepository<Beer>>(); var fakeBeerTypeRepository = new Mock<IRepository<BeerType>>(); var fakeBreweryRepository = new Mock<IRepository<Brewery>>(); var sut = new BeersController(fakeBeerRepository.Object, fakeBreweryRepository.Object, fakeBeerTypeRepository.Object); sut.WithCallTo(x => x.Edit(new Beer(), null)).ShouldRedirectToRoute(""); }