Exemplo n.º 1
0
        public void ShouldGiveHttpNotFoundWhenBreweryIdNotExistsEdit()
        {
            var fakeRepository = new Mock<IRepository<Brewery>>();

            var sut = new BreweriesController(fakeRepository.Object);

            sut.WithCallTo(x => x.Edit(1)).ShouldGiveHttpStatus(HttpStatusCode.NotFound);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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"));
        }
Exemplo n.º 4
0
        public void ShouldRenderCreateView()
        {
            var fakeRepository = new Mock<IRepository<Brewery>>();

            var sut = new BreweriesController(fakeRepository.Object);

            sut.WithCallTo(x => x.Create()).ShouldRenderDefaultView();
        }
Exemplo n.º 5
0
        public void ShouldRenderIndexViewAfterCreatingNewBrewery()
        {
            var fakeRepository = new Mock<IRepository<Brewery>>();

            var sut = new BreweriesController(fakeRepository.Object);

            sut.WithCallTo(x => x.Create(new Brewery())).ShouldRedirectToRoute("");
        }
Exemplo n.º 6
0
        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();
        }
Exemplo n.º 7
0
        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();
        }