Пример #1
0
        public void AddMethodOk()
        {
            clsFilmRatingCollection AllFilmRatings = new clsFilmRatingCollection();
            clsFilmRating           TestItem       = new clsFilmRating();

            TestItem.FilmId = 5;
            TestItem.UserId = 2;
            TestItem.Rating = 4.5F;
            AllFilmRatings.ThisFilmRating = TestItem;
            AllFilmRatings.Add();
            AllFilmRatings.ThisFilmRating.Find(TestItem.FilmId, TestItem.UserId);
            Assert.AreEqual(AllFilmRatings.ThisFilmRating, TestItem);
        }
Пример #2
0
        public void DeleteMethodOk()
        {
            clsFilmRatingCollection AllFilmRatings = new clsFilmRatingCollection();
            clsFilmRating           TestItem       = new clsFilmRating();

            TestItem.FilmId = 2459;
            TestItem.UserId = 2;
            TestItem.Rating = 5;
            AllFilmRatings.ThisFilmRating = TestItem;
            AllFilmRatings.Add();
            AllFilmRatings.ThisFilmRating.Find(TestItem.FilmId, TestItem.UserId);
            AllFilmRatings.Delete();
            Boolean found = AllFilmRatings.ThisFilmRating.Find(TestItem.FilmId, TestItem.UserId);

            Assert.IsFalse(found);
        }
        protected void ddlRating_SelectedIndexChanged(object sender, EventArgs e)
        {
            bool userLoggedIn = HttpContext.Current.User.Identity.IsAuthenticated;

            if (userLoggedIn)
            {
                clsFilmRatingCollection AllRatings = new clsFilmRatingCollection();
                AllRatings.ThisFilmRating.UserId = Convert.ToInt32(Session["UserId"]);
                AllRatings.ThisFilmRating.FilmId = Convert.ToInt32(Session["FilmId"]);
                AllRatings.ThisFilmRating.Rating = float.Parse(ddlRating.SelectedValue);

                if (ratingExists == true)
                {
                    AllRatings.Update();
                }
                else
                {
                    AllRatings.Add();
                }
            }
        }
Пример #4
0
        public void UpdateMethodOk()
        {
            clsFilmRatingCollection AllFilmRatings = new clsFilmRatingCollection();
            clsFilmRating           testItem       = new clsFilmRating();
            Single filmId = 2;
            Single userId = 2;

            testItem.FilmId = filmId;
            testItem.UserId = userId;
            testItem.Rating = 4f;
            AllFilmRatings.ThisFilmRating = testItem;
            AllFilmRatings.Add();

            testItem.FilmId = filmId;
            testItem.UserId = userId;
            testItem.Rating = 5f;
            AllFilmRatings.ThisFilmRating = testItem;
            AllFilmRatings.Update();

            AllFilmRatings.ThisFilmRating.Find(filmId, userId);
            Assert.AreEqual(AllFilmRatings.ThisFilmRating, testItem);
        }