예제 #1
0
        public void RedirectToActionCheckOrders()
        {
            //Arrange
            var comicServiceMock = new Mock <IComicService>();
            var orderServiceMock = new Mock <IOrderService>();

            //Act
            var adminController = new ComicShop.Web.Areas.Admin.Controllers.AdminController(
                comicServiceMock.Object, orderServiceMock.Object);

            //Assert
            adminController
            .WithCallTo(c => c.ProceedOrderById(1))
            .ShouldRedirectTo(x => x.CheckOrders);
        }
예제 #2
0
        public void ReturnView()
        {
            //Arrange
            var comicServiceMock = new Mock <IComicService>();
            var orderServiceMock = new Mock <IOrderService>();

            //Act
            var adminController = new ComicShop.Web.Areas.Admin.Controllers.AdminController(
                comicServiceMock.Object, orderServiceMock.Object);

            //Assert
            adminController
            .WithCallTo(c => c.Index())
            .ShouldRenderDefaultView();
        }
예제 #3
0
        public void RedirectToIndexActionResultWhenModelStateIsValid()
        {
            //Arrange
            var   comicServiceMock = new Mock <IComicService>();
            var   orderServiceMock = new Mock <IOrderService>();
            Comic comic            = new Comic();

            //Act
            var adminController = new ComicShop.Web.Areas.Admin.Controllers.AdminController(
                comicServiceMock.Object, orderServiceMock.Object);

            //Assert
            adminController
            .WithCallTo(c => c.AddComic(comic))
            .ShouldRedirectTo(x => x.Index);
        }
예제 #4
0
        public void ReturnDefaultViewWhenModelStateIsNotValid()
        {
            //Arrange
            var   comicServiceMock = new Mock <IComicService>();
            var   orderServiceMock = new Mock <IOrderService>();
            Comic comic            = new Comic();

            //Act
            var adminController = new ComicShop.Web.Areas.Admin.Controllers.AdminController(
                comicServiceMock.Object, orderServiceMock.Object);

            adminController.ModelState.AddModelError("testError", "error detected");

            //Assert
            adminController
            .WithCallTo(c => c.AddComic(comic))
            .ShouldRenderDefaultView();
        }
예제 #5
0
        public void ReturnView()
        {
            //Arrange
            var   comicServiceMock = new Mock <IComicService>();
            var   orderServiceMock = new Mock <IOrderService>();
            Comic comic            = new Comic()
            {
                Id = 1
            };

            comicServiceMock.Setup(x => x.GetComicById(1)).Returns(comic);

            //Act
            var adminController = new ComicShop.Web.Areas.Admin.Controllers.AdminController(
                comicServiceMock.Object, orderServiceMock.Object);

            //Assert
            adminController
            .WithCallTo(c => c.EditComic(1))
            .ShouldRenderDefaultView();
        }
예제 #6
0
        public void ReturnView()
        {
            //Arrange
            var   comicServiceMock = new Mock <IComicService>();
            var   orderServiceMock = new Mock <IOrderService>();
            Order order            = new Order();
            var   ordersList       = new List <Order>()
            {
                order
            };

            orderServiceMock.Setup(x => x.GetAllOrders()).Returns(ordersList.AsQueryable);

            //Act
            var adminController = new ComicShop.Web.Areas.Admin.Controllers.AdminController(
                comicServiceMock.Object, orderServiceMock.Object);

            //Assert
            adminController
            .WithCallTo(c => c.CheckOrders())
            .ShouldRenderDefaultView();
        }