예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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("");
        }
예제 #4
0
        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();
        }
예제 #5
0
        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();
        }
예제 #6
0
        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();
        }
예제 #7
0
        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("");
        }