Exemplo n.º 1
0
        public void CreateViewLoads()
        {
            var actual = (ViewResult)controller.Create();

            // assert
            Assert.AreEqual("Create", actual.ViewName);
        }
        public void BrewariesController_AddAction()
        {
            BreweriesController controller = new BreweriesController(new FakeRepositories.FakeBrewaryRepository());

            Brewery brew = new Brewery()
            {
                Name      = "Sleeman",
                Address   = "Oakville",
                YTDSales  = 500,
                BreweryId = 5
            };

            System.Web.Mvc.RedirectToRouteResult result = controller.Create(brew) as System.Web.Mvc.RedirectToRouteResult;

            Assert.IsNotNull(result);
        }
        public void BrewariesController_Edit()
        {
            BreweriesController controller = new BreweriesController(new FakeRepositories.FakeBrewaryRepository());

            Brewery brew = new Brewery()
            {
                Name      = "Molson",
                Address   = "Toronto",
                YTDSales  = 5030,
                BreweryId = 1
            };

            System.Web.Mvc.RedirectToRouteResult result = controller.Create(brew) as System.Web.Mvc.RedirectToRouteResult;
            System.Web.Mvc.RedirectToRouteResult edit   = controller.Edit(brew) as System.Web.Mvc.RedirectToRouteResult;

            Assert.IsNotNull(result);
            Assert.IsNotNull(edit);
        }
        public void BrewariesController_Delete()
        {
            BreweriesController controller = new BreweriesController(new FakeRepositories.FakeBrewaryRepository());

            Brewery brew = new Brewery()
            {
                Name      = "Molson",
                Address   = "Toronto",
                YTDSales  = 5030,
                BreweryId = 1
            };

            System.Web.Mvc.RedirectToRouteResult result = controller.Create(brew) as System.Web.Mvc.RedirectToRouteResult;

            System.Web.Mvc.RedirectToRouteResult deleteResult = controller.DeleteConfirmed(1) as System.Web.Mvc.RedirectToRouteResult;

            System.Web.Mvc.RedirectToRouteResult model = controller.Details(1) as System.Web.Mvc.RedirectToRouteResult;

            Assert.IsNotNull(result);
            Assert.IsNotNull(deleteResult);
            Assert.IsNull(model);
        }