Ejemplo n.º 1
0
        public void Test_UserHostSearchDelete()
        {
            var value = new UserHostSearchDelete(
                new UserHostSearch
                {
                    Id = 1,
                    Title = "test"
                }
            );

            Assert.AreEqual(1, value.Id, "Id");
            Assert.AreEqual("test", value.Title, "Title");
        }
Ejemplo n.º 2
0
        public void Test_HostSearchController_Delete_Post()
        {
            PrincipalHelper.Create();

            var value = new UserHostSearchDelete
            {
                Id = 1
            };

            var redirectToRouteResult = this.HostSearchController.Delete(value) as RedirectToRouteResult;

            Assert.IsNotNull(redirectToRouteResult, "RedirectToRouteResult");
            Assert.AreEqual(UsersAdministrationRoutes.HostSearchCreate, redirectToRouteResult.RouteName);

            PrincipalHelper.Clear();

            var notAuthorizedResult = this.HostSearchController.Delete(value) as NotAuthorizedResult;

            Assert.IsNotNull(notAuthorizedResult, "NotAuthorizedResult");
        }
Ejemplo n.º 3
0
        public ActionResult Delete(UserHostSearchDelete value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            var search = UserHostSearchService.GetById(value.Id);

            if (search == null)
            {
                return base.HttpNotFound();
            }

            var privilege = new UserHostSearchPrivilege();

            if (!privilege.CanDelete(search))
            {
                return NotAuthorized();
            }

            this.UserHostSearchService.Delete(search);

            return base.RedirectToRoute(UsersAdministrationRoutes.HostSearchCreate);
        }