public void Test_AttachmentRuleDeleteTest() { var value = new AttachmentRuleDelete( new AttachmentRule { Id = 1, Group = "test", FileType = "test2" } ); Assert.AreEqual(1, value.Id, "Id"); Assert.AreEqual("test", value.Group, "Group"); Assert.AreEqual("test2", value.FileType, "FileType"); }
public ActionResult Delete(AttachmentRuleDelete value) { if (value == null) { throw new ArgumentNullException("value"); } var rule = this.AttachmentRuleService.GetById(value.Id); if (rule == null) { return base.HttpNotFound(); } var privilege = new AttachmentRulePrivilege(); if (!privilege.CanDelete(rule)) { return NotAuthorized(); } this.AttachmentRuleService.Delete(rule); return base.RedirectToRoute(AdministrationRoutes.AttachmentRuleIndex); }
public void Test_AttachmentRuleController_Delete_Post() { PrincipalHelper.Create(); var value = new AttachmentRuleDelete { Id = 0 }; var notFoundResult = this.AttachmentRuleController.Delete(value) as HttpNotFoundResult; Assert.IsNotNull(notFoundResult, "HttpNotFoundResult"); value.Id = 1; var redirectToRouteResult = this.AttachmentRuleController.Delete(value) as RedirectToRouteResult; Assert.IsNotNull(redirectToRouteResult, "RedirectToRouteResult"); Assert.AreEqual(AdministrationRoutes.AttachmentRuleIndex, redirectToRouteResult.RouteName, "RouteName"); PrincipalHelper.Clear(); var notAuthorizedResult = this.AttachmentRuleController.Delete(value) as NotAuthorizedResult; Assert.IsNotNull(notAuthorizedResult, "NotAuthorizedResult"); }