public void ShouldGiveHttpNotFoundWhenBreweryIdNotExistsEdit() { var fakeRepository = new Mock<IRepository<Brewery>>(); var sut = new BreweriesController(fakeRepository.Object); sut.WithCallTo(x => x.Edit(1)).ShouldGiveHttpStatus(HttpStatusCode.NotFound); }
public void ShouldGiveBadRequestErrorWhenIdIsNullEdit() { var fakeRepository = new Mock<IRepository<Brewery>>(); var sut = new BreweriesController(fakeRepository.Object); sut.WithCallTo(x => x.Edit(null as int?)).ShouldGiveHttpStatus(HttpStatusCode.BadRequest); }
public void ShouldGiveBreweryWhenIdExists() { var fakeRepository = new Mock<IRepository<Brewery>>(); var sut = new BreweriesController(fakeRepository.Object); fakeRepository.Setup(x => x.GetById(2)).Returns(new Brewery { Name = "Aas" }); sut.WithCallTo(x => x.Details(2)) .ShouldRenderDefaultView() .WithModel<Brewery>(x => x.Name.Equals("Aas")); }
public void ShouldRenderCreateView() { var fakeRepository = new Mock<IRepository<Brewery>>(); var sut = new BreweriesController(fakeRepository.Object); sut.WithCallTo(x => x.Create()).ShouldRenderDefaultView(); }
public void ShouldRenderIndexViewAfterCreatingNewBrewery() { var fakeRepository = new Mock<IRepository<Brewery>>(); var sut = new BreweriesController(fakeRepository.Object); sut.WithCallTo(x => x.Create(new Brewery())).ShouldRedirectToRoute(""); }
public void ShouldRenderEditViewWhenBreweryHasBeenEdited() { var fakeRepository = new Mock<IRepository<Brewery>>(); var sut = new BreweriesController(fakeRepository.Object); fakeRepository.Setup(x => x.GetById(2)).Returns(new Brewery()); sut.WithCallTo(x => x.Edit(2)).ShouldRenderDefaultView(); }
public void ShouldRenderDefaultViewWhenInvalidModelState() { var fakeRepository = new Mock<IRepository<Brewery>>(); var sut = new BreweriesController(fakeRepository.Object); sut.ModelState.AddModelError("1", "Error"); sut.WithCallTo(x => x.Create(new Brewery())).ShouldRenderDefaultView(); }