public void AddMethodOK()
        {
            //Create an instance of the class we want to create
            clsFilmCollection AllFilms = new clsFilmCollection();
            //Create the item of test data
            clsFilm TestItem = new clsFilm();
            //Variable to store the primary kjey
            Int32 PrimaryKey = 0;

            //Set its properties
            TestItem.Title       = "Punch 5: Punch Yet Again Even More Hardererer";
            TestItem.Duration    = 80;
            TestItem.AgeRatingID = 5;
            TestItem.GenreID     = 5;
            //Set ThisFilm to the test data
            AllFilms.ThisFilm = TestItem;
            //Add the record
            PrimaryKey = AllFilms.Add();
            //Set the primary key of the test data
            TestItem.FilmID = PrimaryKey;
            //Find the record
            AllFilms.ThisFilm.Find(PrimaryKey);
            //Test to see that the two values are the same
            Assert.AreEqual(AllFilms.ThisFilm, TestItem);
        }
        public void UpdateMethodOK()
        {
            clsFilmCollection AllFilms   = new clsFilmCollection();
            clsFilm           TestFilm   = new clsFilm();
            Int32             PrimaryKey = 0;

            TestFilm.FilmName        = "Frazers Film";
            TestFilm.FilmDescription = "test description, test description, test description, " +
                                       "test description, test description, ";
            TestFilm.FilmCertificate   = "12";
            TestFilm.FilmReleaseDate   = DateTime.Now.Date;
            TestFilm.FilmDepartureDate = DateTime.Now.Date.AddYears(1);

            AllFilms.ThisFilm = TestFilm;
            PrimaryKey        = AllFilms.Add();
            TestFilm.FilmID   = PrimaryKey;

            TestFilm.FilmName        = "Frazers Film2";
            TestFilm.FilmDescription = "test description, test description, test description, " +
                                       "test description, test description2, ";
            TestFilm.FilmCertificate   = "15";
            TestFilm.FilmReleaseDate   = DateTime.Now.Date;
            TestFilm.FilmDepartureDate = DateTime.Now.Date.AddYears(1);

            AllFilms.ThisFilm = TestFilm;

            AllFilms.Update();

            AllFilms.ThisFilm.Find(PrimaryKey);
            Assert.AreEqual(AllFilms.ThisFilm, TestFilm);
        }
        public void SearchForFilmMethodOk()
        {
            clsFilmCollection AllFilms   = new clsFilmCollection();
            string            searchText = "Story";

            Assert.IsNotNull(AllFilms.SearchForFilm(searchText));
        }
        public void FilterByTitleTestDataFound()
        {
            //Create an instance of the filtered data
            clsFilmCollection FilteredFilms = new clsFilmCollection();
            //Variable to store outcome
            Boolean OK = true;

            //Apply a Title that doesn exist
            FilteredFilms.FilterByTitle("Zzzzzzzz");
            //Check that the correct number of records are found
            if (FilteredFilms.Count == 2)
            {
                //Check that the first record is ID 36
                if (FilteredFilms.FilmList[0].FilmID != 36)
                {
                    OK = false;
                }
                //Check that the first record is ID 37
                if (FilteredFilms.FilmList[0].FilmID != 37)
                {
                    OK = false;
                }
            }
            else
            {
                OK = false;
            }
            //Test to see that there are no records
            Assert.IsTrue(OK);
        }
 protected void btnYes_Click(object sender, EventArgs e)
 {
     clsFilmCollection FilmCollection = new clsFilmCollection();
     FilmCollection.ThisFilm.Find(FilmId);
     FilmCollection.Delete();
     Response.Redirect("FilmList.aspx");
 }
        public void ReportByFilmNameMethodOK()
        {
            clsFilmCollection AllFilms      = new clsFilmCollection();
            clsFilmCollection FilteredFilms = new clsFilmCollection();

            FilteredFilms.ReportByFilmName("");
            Assert.AreEqual(AllFilms.Count, FilteredFilms.Count);
        }
        public void CountPropertyOk()
        {
            clsFilmCollection AllFilms = new clsFilmCollection();
            Int32             count    = 9755;

            AllFilms.Count = count;
            Assert.AreEqual(AllFilms.Count, count);
        }
        public void InstanceOK()
        {
            //Create an instance of the class we want to create
            clsFilmCollection AllFilms = new clsFilmCollection();

            //Test to see that it exists
            Assert.IsNotNull(AllFilms);
        }
        public void FilmAlreadyExistsMethodOk()
        {
            clsFilmCollection AllFilms = new clsFilmCollection();
            Boolean           found    = false;
            string            title    = "Dune (2021)";

            found = AllFilms.FilmAlreadyExistsCheck(title);
            Assert.IsTrue(found);
        }
Beispiel #10
0
        protected void grdAllFilms_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            Int32             filmId   = Convert.ToInt32(((Label)grdAllFilms.Rows[e.RowIndex].FindControl("lblFilmId")).Text);
            clsFilmCollection AllFilms = new clsFilmCollection();

            AllFilms.ThisFilm.FilmId = filmId;
            AllFilms.Delete();
            LoadData();
        }
        public void FIlterByTitleNoneFound()
        {
            //Create an instance of the filtered data
            clsFilmCollection FilteredFilms = new clsFilmCollection();

            //Apply a title that doesn't exist
            FilteredFilms.FilterByTitle("Zzzzzzzz!");
            //Test to see that there are no records
            Assert.AreEqual(0, FilteredFilms.Count);
        }
        public void ThisFilmPropertyOk()
        {
            clsFilmCollection AllFilms = new clsFilmCollection();
            clsFilm           testFilm = new clsFilm();

            testFilm.FilmId   = 1;
            testFilm.Title    = "Midsommar(2019)";
            AllFilms.ThisFilm = testFilm;
            Assert.AreEqual(AllFilms.ThisFilm, testFilm);
        }
    protected void btnApply_Click(object sender, EventArgs e)
    {
        clsFilmCollection Films = new clsFilmCollection();

        Films.ReportByFilmName(txtFilmNameFilter.Text);
        lstFilmList.DataSource     = Films.FilmList;
        lstFilmList.DataValueField = "FilmId";
        lstFilmList.DataTextField  = "FilmName";
        lstFilmList.DataBind();
    }
    protected void btnClear_Click(object sender, EventArgs e)
    {
        clsFilmCollection Films = new clsFilmCollection();

        Films.ReportByFilmName("");
        txtFilmNameFilter.Text     = "";
        lstFilmList.DataValueField = "FilmId";
        lstFilmList.DataTextField  = "FilmName";
        lstFilmList.DataBind();
    }
Beispiel #15
0
        public void CountPropertyOkay()
        {
            //create instance of class we want to create
            clsFilmCollection AllFilms = new clsFilmCollection();
            //create some test data to assign to the property
            Int32 SomeCount = 0;

            //assign the data to the property
            AllFilms.Count = SomeCount;
        }
        public void CountMatchesList()
        {
            clsFilmCollection Films    = new clsFilmCollection();
            List <clsFilm>    testList = new List <clsFilm>();
            clsFilm           testItem = new clsFilm();

            testItem.FilmId = 1;
            testItem.Title  = "King Kong (2005)";
            testList.Add(testItem);
            Films.AllFilms = testList;
            Assert.AreEqual(Films.Count, testList.Count);
        }
        public void FilterByTitleMethodOK()
        {
            //Create an instance of the class containing unfiltered results
            clsFilmCollection AllFilms = new clsFilmCollection();
            //Create an instance of the filtered data
            clsFilmCollection FilteredFilms = new clsFilmCollection();

            //Apply a blank string (should return all records)
            FilteredFilms.FilterByTitle("");
            //Test to see that the two values are the same
            Assert.AreEqual(AllFilms.Count, FilteredFilms.Count);
        }
    void DisplayAddress()
    {
        clsFilmCollection FilmList = new clsFilmCollection();

        FilmList.ThisFilm.Find(FilmId);

        txtFilmName.Text  = FilmList.ThisFilm.FilmName;
        txtFilmDesc.Text  = FilmList.ThisFilm.FilmDescription;
        txtCert.Text      = FilmList.ThisFilm.FilmCertificate;
        txtRelease.Text   = FilmList.ThisFilm.FilmReleaseDate.ToString();
        txtDeparture.Text = FilmList.ThisFilm.FilmDepartureDate.ToString();
    }
        public void AddMethodOk()
        {
            clsFilmCollection AllFilms   = new clsFilmCollection();
            clsFilm           TestItem   = new clsFilm();
            Int32             primaryKey = 0;

            TestItem.Title    = "Top Gun: Maverick (2021)";
            AllFilms.ThisFilm = TestItem;
            primaryKey        = AllFilms.Add();
            TestItem.FilmId   = primaryKey;
            AllFilms.ThisFilm.Find(primaryKey);
            Assert.AreEqual(AllFilms.ThisFilm, TestItem);
        }
 public static List<string> SearchFilms(string prefixTest, int count)
 {
     clsFilmCollection AllFilms = new clsFilmCollection();
     List<string> filmTitles = new List<string>();
     foreach (clsFilm aFilm in AllFilms.AllFilms)
     {
         if (aFilm.Title.Contains(prefixTest))
         {
             filmTitles.Add(aFilm.Title);
         }
     }
     return filmTitles;
 }
Beispiel #21
0
        protected void grdAllFilms_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            clsFilmCollection AllFilmsInDatabase = new clsFilmCollection();
            string            title = ((TextBox)grdAllFilms.Rows[e.RowIndex].FindControl("txtTitle")).Text;

            Session["Title"]   = title;
            AllFilmsInDatabase = new clsFilmCollection();

            foreach (string error in AllFilmsInDatabase.ThisFilm.Valid(title))
            {
                Label lblError = new Label();
                lblError.Text = error;
                pnlActionFilmErrorBody.Controls.Add(lblError);
            }
        }
Beispiel #22
0
        public void ThisFilmPropertyOK()
        {
            clsFilmCollection AllFilms = new clsFilmCollection();
            clsFilm           TestFilm = new clsFilm();

            TestFilm.FilmName          = "test film";
            TestFilm.FilmDescription   = "test description";
            TestFilm.FilmCertificate   = "u";
            TestFilm.FilmReleaseDate   = DateTime.Now.Date;
            TestFilm.FilmShowing       = true;
            TestFilm.FilmDepartureDate = DateTime.Now.Date.AddYears(1);

            AllFilms.ThisFilm = TestFilm;

            Assert.AreEqual(AllFilms.ThisFilm, TestFilm);
        }
        public void UpdateMethodOk()
        {
            clsFilmCollection AllFilms   = new clsFilmCollection();
            clsFilm           TestItem   = new clsFilm();
            Int32             primaryKey = 0;

            TestItem.Title    = "No Time To Die (2020)";
            AllFilms.ThisFilm = TestItem;
            primaryKey        = AllFilms.Add();
            TestItem.FilmId   = primaryKey;

            TestItem.Title    = "No Time To Die (2021)";
            AllFilms.ThisFilm = TestItem;
            AllFilms.Update();
            AllFilms.ThisFilm.Find(primaryKey);
            Assert.AreEqual(AllFilms.ThisFilm, TestItem);
        }
        public void ThisFilmPropertyOK()
        {
            //Create an instance of the class we want to create
            clsFilmCollection AllFilms = new clsFilmCollection();
            //Create some test data to assign to the property
            clsFilm TestFilm = new clsFilm();

            //Set the properties of the test object
            TestFilm.Title       = "Punch 3: Punch Harderer";
            TestFilm.Duration    = 75;
            TestFilm.AgeRatingID = 4;
            TestFilm.GenreID     = 1;
            //Assign the data to the property
            AllFilms.ThisFilm = TestFilm;
            //Test to see that the two values are the same
            Assert.AreEqual(AllFilms.ThisFilm, TestFilm);
        }
Beispiel #25
0
        public void DeleteByFilmIdMethodOk()
        {
            bool found;
            clsFilmGenreCollection AllFilmGenres = new clsFilmGenreCollection();
            clsFilmCollection      AllFilms      = new clsFilmCollection();

            AllFilms.ThisFilm.Title = "test";
            Int32 primaryKey = AllFilms.Add();
            Int32 genreId    = 1;

            AllFilmGenres.ThisFilmGenre.FilmId  = primaryKey;
            AllFilmGenres.ThisFilmGenre.GenreId = genreId;
            AllFilmGenres.Add();
            AllFilmGenres.DeleteByFilmId();
            found = AllFilmGenres.ThisFilmGenre.Find(primaryKey, genreId);
            Assert.IsFalse(found);
        }
    protected void ButtonOK_Click(object sender, EventArgs e)
    {
        clsFilm AFilm = new clsFilm();

        string  FilmName          = txtFilmName.Text;
        string  FilmDescription   = txtFilmDesc.Text;
        string  FilmCertificate   = txtCert.Text;
        string  FilmReleaseDate   = txtRelease.Text;
        string  FilmDepartureDate = txtDeparture.Text;
        Boolean FilmShowing       = showingCheck.Checked;
        string  Error             = "";

        Error = AFilm.Valid(FilmName, FilmDescription, FilmCertificate, FilmReleaseDate, FilmDepartureDate);
        if (Error == "")
        {
            AFilm.FilmID            = FilmId;
            AFilm.FilmName          = FilmName;
            AFilm.FilmDescription   = FilmDescription;
            AFilm.FilmCertificate   = FilmCertificate;
            AFilm.FilmReleaseDate   = Convert.ToDateTime(FilmReleaseDate);
            AFilm.FilmDepartureDate = Convert.ToDateTime(FilmDepartureDate);

            clsFilmCollection FilmList = new clsFilmCollection();

            if (FilmId == -1)
            {
                FilmList.ThisFilm = AFilm;
                FilmList.Add();
            }
            else
            {
                FilmList.ThisFilm.Find(FilmId);
                FilmList.ThisFilm = AFilm;
                FilmList.Update();
            }

            Response.Redirect("FilmViewer.aspx");

            //Session["AFilm"] = AFilm;
        }
        else
        {
            lblError.Text = Error;
        }
    }
        protected void Page_Load(object sender, EventArgs e)
        {
            pnlAllSearchResults.Visible = false;
            pnlError.Visible            = false;

            if (!IsPostBack)
            {
                try
                {
                    string searchText = Request.QueryString["searchText"];
                    Session["searchText"] = searchText;
                    CheckIfUserIsLoggedIn();

                    clsFilmCollection AllFilms      = new clsFilmCollection();
                    clsDataConnection DB            = new clsDataConnection();
                    clsDynamicPanel   aDynamicPanel = new clsDynamicPanel();

                    if (AllFilms.SearchForFilm(searchText).Count != 0)
                    {
                        foreach (clsFilm aFilm in AllFilms.SearchForFilm(searchText))
                        {
                            DB = new clsDataConnection();
                            DB.AddParameter("@FilmId", aFilm.FilmId);
                            DB.Execute("sproc_tblLinksFilterByFilmId");

                            string imdbId = DB.DataTable.Rows[0]["ImdbId"].ToString();
                            pnlActualSearchResults.Controls.Add(aDynamicPanel.GenerateSearchResultsPanel(aFilm.Title, imdbId));
                        }
                        GenerateMoods();
                        pnlAllSearchResults.Visible = true;
                    }
                    else
                    {
                        pnlActualSearchResults.Controls.Clear();
                        pnlActualSearchResults.Controls.Add(aDynamicPanel.GenerateEmptySearchResultsPanel());
                    }
                }
                catch
                {
                    pnlError.Visible = true;
                }
            }
        }
Beispiel #28
0
        void LoadData()
        {
            try
            {
                clsFilmCollection AllFilmsInDatabase = new clsFilmCollection();
                AllFilmsInDatabase     = new clsFilmCollection();
                grdAllFilms.DataSource = AllFilmsInDatabase.AllFilms;
                grdAllFilms.DataBind();

                if (!string.IsNullOrEmpty(txtFilmSearch.Text.Trim()))
                {
                    grdAllFilms.DataSource = AllFilmsInDatabase.SearchForFilm(txtFilmSearch.Text);
                    grdAllFilms.DataBind();
                }
            }
            catch
            {
                pnlError.Visible = true;
            }
        }
Beispiel #29
0
        public void ListAndCountOK()
        {
            clsFilmCollection AllFilms = new clsFilmCollection();

            List <clsFilm> TestList = new List <clsFilm>();

            clsFilm TestFilm = new clsFilm();

            TestFilm.FilmName          = "test film";
            TestFilm.FilmDescription   = "test description";
            TestFilm.FilmCertificate   = "u";
            TestFilm.FilmReleaseDate   = DateTime.Now.Date;
            TestFilm.FilmShowing       = true;
            TestFilm.FilmDepartureDate = DateTime.Now.Date.AddYears(1);

            TestList.Add(TestFilm);

            AllFilms.FilmList = TestList;

            Assert.AreEqual(AllFilms.Count, TestList.Count);
        }
        public void DeleteMethodOK()
        {
            clsFilmCollection AllFilms   = new clsFilmCollection();
            clsFilm           TestFilm   = new clsFilm();
            Int32             PrimaryKey = 0;

            TestFilm.FilmName        = "Frazers Film";
            TestFilm.FilmDescription = "test description, test description, test description, " +
                                       "test description, test description, ";
            TestFilm.FilmCertificate   = "12";
            TestFilm.FilmReleaseDate   = DateTime.Now.Date;
            TestFilm.FilmDepartureDate = DateTime.Now.Date.AddYears(1);

            AllFilms.ThisFilm = TestFilm;
            PrimaryKey        = AllFilms.Add();
            TestFilm.FilmID   = PrimaryKey;
            AllFilms.ThisFilm.Find(PrimaryKey);
            AllFilms.Delete();
            Boolean Found = AllFilms.ThisFilm.Find(PrimaryKey);

            Assert.IsFalse(Found);
        }