Ejemplo n.º 1
0
        public void Save_SetFailAdv_ItsOkReturnCreatePage()
        {
            var controller = new AdvertisementsController();

            var advertisementView = new CreateAdvertisementView();

            advertisementView.Price = "-1";
            var result = controller.Save(advertisementView);

            Assert.IsInstanceOf <CreateAdvertisementView>((result as ViewResult).Model);
        }
Ejemplo n.º 2
0
        public void Save_SetValidAdv_ItsOkReturnListAdv()
        {
            var controller = new AdvertisementsController();

            var advertisementView = new CreateAdvertisementView()
            {
                Contacts    = "т. 5745773",
                Description = "Пример",
                Name        = "Пример",
                Price       = "1000"
            };
            var result = controller.Save(advertisementView);

            Assert.IsInstanceOf <RedirectToRouteResult>(result);

            Assert.IsTrue((result as RedirectToRouteResult).RouteValues.TryGetValue("action", "List"), "Контроллер должен быть Advertisements");
            Assert.IsTrue((result as RedirectToRouteResult).RouteValues.TryGetValue("action", "List"), "Действие должно быть List");
        }