public void AddFavoritoTest() { UserProfile userProfile = CreateTestUserProfile(); Favorito favorito = opinadorService.AddFavorito(userProfile.usrId, PRODUCTO_ID, "bookmark", "interesante"); List <Favorito> favoritos = opinadorService.FindFavoritosByUsrId(userProfile.usrId, START_INDEX, COUNT); Assert.IsTrue(favoritos.Count == 1); Assert.IsTrue(favoritos.Contains(favorito)); }
protected void Page_Load(object sender, EventArgs e) { if (!SessionManager.IsUserAuthenticated(this.Context)) { Response.Redirect("./User/Authentication.aspx?ReturnUrl=../ShowFavorites.aspx"); } /* Hide the links */ lnkAnterior.Visible = false; lnkSiguiente.Visible = false; /* Get de Service */ IUnityContainer container = (IUnityContainer)HttpContext.Current.Application["unityContainer"]; IOpinadorService opinadorService = container.Resolve <IOpinadorService>(); int startIndex; UserSession userSession = (UserSession)Context.Session["userSession"]; long idUser = userSession.UserProfileId; try { startIndex = Int32.Parse(Request.Params.Get("startIndex")); } catch (ArgumentNullException) { startIndex = 0; } Int32 count = 10; int numValor = opinadorService.FindFavoritosByUsrId(idUser, startIndex, count).Count(); if (numValor == 0) { lblNoFavoritos.Visible = true; } this.gvFavoritos.DataSource = opinadorService.FindFavoritosByUsrId(idUser, startIndex, count); this.gvFavoritos.DataBind(); /* "Previous" link */ if ((startIndex - count) >= 0) { String url = "./ShowFavorites.aspx?" + "&startIndex=" + (startIndex - count); this.lnkAnterior.NavigateUrl = Response.ApplyAppPathModifier(url); this.lnkAnterior.Visible = true; } /* "Next" link */ if ((startIndex + count) < numValor) { String url = "./ShowFavorites.aspx" + "&startIndex=" + (startIndex + count); this.lnkSiguiente.NavigateUrl = Response.ApplyAppPathModifier(url); this.lnkSiguiente.Visible = true; } }