public void DeleteComentarioTest() { UserProfile userProfile = CreateTestUserProfile(); ComentarioEtiquetaBlock comentarioTest = CreateTestComentario(userProfile.usrId); Assert.IsTrue(opinadorService.FindComentariosByProductoId(PRODUCTO_ID, START_INDEX, COUNT).Contains(comentarioTest.Comentario)); Assert.IsTrue(opinadorService.GetNumberOfComentariosByProductoId(PRODUCTO_ID) == 1); opinadorService.DeleteComentario(comentarioTest.Comentario.comentarioId); Assert.IsFalse(opinadorService.FindComentariosByProductoId(PRODUCTO_ID, START_INDEX, COUNT).Contains(comentarioTest.Comentario)); Assert.IsTrue(opinadorService.GetNumberOfComentariosByProductoId(PRODUCTO_ID) == 0); }
protected void Page_Load(object sender, EventArgs e) { if (!SessionManager.IsUserAuthenticated(Context)) { Response.Redirect(Response.ApplyAppPathModifier("./User/Authentication.aspx?ReturnUrl=../RemoveComment.aspx")); } IUnityContainer container = (IUnityContainer)HttpContext.Current.Application["unityContainer"]; IOpinadorService opinadorService = container.Resolve <IOpinadorService>(); IComentarioDao comentarioDao = container.Resolve <IComentarioDao>(); long idComment = long.Parse(Request.Params.Get("id")); long user = comentarioDao.Find(idComment).usrId; if (!user.Equals(SessionManager.GetUserSession(Context).UserProfileId)) { Response.Redirect(Response.ApplyAppPathModifier("./NonExistAutorization.aspx")); } opinadorService.DeleteComentario(idComment); Response.Redirect(Response.ApplyAppPathModifier("./MainPage.aspx")); }