Exemple #1
0
        public void AddNullStringKeyword()
        {
            String expectedkeyword = null;
            Paper existingpaper = new Paper();

            existingpaper.addKeyword(expectedkeyword);
        }
Exemple #2
0
        public void AddNumericalKeyword()
        {
            String expectedkeyword = "1234";
            Paper existingpaper = new Paper();

            existingpaper.addKeyword(expectedkeyword);
        }
Exemple #3
0
        public void AddEmptyStringKeyword()
        {
            String expectedkeyword = "";
            Paper existingpaper = new Paper();

            existingpaper.addKeyword(expectedkeyword);
        }
        public void SearchNormal_ExistingKeyword_MultiplePapers()
        {
            //  create database, existing papers array, and define existing keyword of "Doppler Effect"
            String existingKeyword = "Doppler Effect";
            Database allPapers = new Database();
            Paper [] existingPaper = new Paper [2];

            //  apply existing keyword across multiple papers and add those papers to database
            for (int i = 0; i < 2; i++)
            {
                //  create paper with existing keyword
                existingPaper[i] = new Paper();
                existingPaper[i].addKeyword(existingKeyword);

                //  add paper to a database
                Database.addPaper(allPapers, existingPaper[i]);
            }

            //  search database using keyword of "Doppler Effect"
            List<Paper> searchedPaper = Database.searchByKeyword(allPapers, existingKeyword);

            //  check if search result returns null (found no matches for "Doppler Effect")
            if (searchedPaper == null) Assert.Fail();

            //  check if search results match the added papers
            Assert.AreEqual(existingPaper[0], searchedPaper[0]);
            Assert.AreEqual(existingPaper[1], searchedPaper[1]);
        }
Exemple #5
0
        public void AddDuplicateKeyword()
        {
            String expectedkeyword = "Testing";
            Paper existingpaper = new Paper();

            existingpaper.addKeyword(expectedkeyword);
            existingpaper.addKeyword(expectedkeyword);
        }
Exemple #6
0
        internal static void addPaper(Database database, Paper existingPaper)
        {
            // verify that arguments are valid
            if (existingPaper == null) throw new ArgumentNullException();
            if (database == null) throw new ArgumentNullException();

            // add paper to database
            Database.getAllPapers(database).Add(existingPaper);
        }
Exemple #7
0
        public void RemoveNormalUniqueKeyword()
        {
            String expectedkeyword = "Testing";
            Paper existingpaper = new Paper();
            Author a = new Author();

            existingpaper.removeKeyword(expectedkeyword);
            List<String> keywords = existingpaper.listKeywords();

            bool removed = keywords.Contains(expectedkeyword);
            Assert.IsFalse(removed);
        }
Exemple #8
0
        public void AddNormalUniqueKeyword()
        {
            String expectedkeyword = "Testing";
            Paper existingpaper = new Paper();
            Author a = new Author();

            existingpaper.addKeyword(expectedkeyword);
            List<String> keywords = existingpaper.listKeywords();
            List<String> authorkeywords = a.listKeywords();

            String actual = keywords.Find(s => s == expectedkeyword);
            Assert.AreEqual(actual, expectedkeyword);

            actual = authorkeywords.Find(s => s == expectedkeyword);
            Assert.AreEqual(actual, expectedkeyword);
        }
        public void SearchNormal_NonExistingKeyword()
        {
            //  create paper with keyword of "Doppler Effect"
            String existingKeyword = "Doppler Effect";
            Paper existingPaper = new Paper();
            existingPaper.addKeyword(existingKeyword);

            //  add paper to a database
            Database allPapers = new Database();
            Database.addPaper(allPapers, existingPaper);

            //  search database using non-existing keyword of "Fusion"
            String nonExistingKeyword = "Fusion";
            List<Paper> searchedPaper = Database.searchByKeyword(allPapers, nonExistingKeyword);

            //  check if search result returns null (found no matches for "Fusion")
            Assert.AreEqual(searchedPaper, null);
        }
        public void SearchNormal_ExistingKeyword_SinglePaper()
        {
            //  create paper with keyword of "Doppler Effect"
            String existingKeyword = "Doppler Effect";
            Paper existingPaper = new Paper();
            existingPaper.addKeyword(existingKeyword);

            //  add paper to a database
            Database allPapers = new Database();
            Database.addPaper(allPapers, existingPaper);

            //  search database using keyword of "Doppler Effect"
            List<Paper> searchedPaper = Database.searchByKeyword(allPapers, existingKeyword);

            //  check if search result returns null (found no matches for "Doppler Effect")
            if (searchedPaper == null) Assert.Fail();

            //  check if search result matches the added paper
            Assert.AreEqual(existingPaper, searchedPaper[0]);
        }
Exemple #11
0
        internal static int getDatabaseIDByPaperReference(Database database, Paper query)
        {
            // verify that arguments are valid
            if (query == null) throw new ArgumentNullException();
            if (database == null) throw new ArgumentNullException();

            // scan through all papers
            for (int i = 0; i < Database.getAllPapers(database).Count; i++)
            {
                // if this paper's reference matches the query's reference, the paper is found
                // return this index
                if (Database.getAllPapers(database).ElementAt(i) == query)
                    return i;
            }

            // return -1 if no paper found
            return -1;
        }
Exemple #12
0
        internal static void deletePaperByPaperReference(Database database, Paper query)
        {
            // verify that arguments are valid
            if (query == null) throw new ArgumentNullException();
            if (database == null) throw new ArgumentNullException();

            // scan through all papers
            for (int i = 0; i < Database.getAllPapers(database).Count; i++)
            {
                // if this paper's reference matches the query's reference, the paper is found
                // delete this paper from database
                if (Database.getAllPapers(database).ElementAt(i) == query)
                    Database.getAllPapers(database).RemoveAt(i);
            }
        }
        public void SearchProblem_NullKeywordGiven()
        {
            //  create paper with keyword of "Doppler Effect"
            String existingKeyword = "Doppler Effect";
            Paper existingPaper = new Paper();
            existingPaper.addKeyword(existingKeyword);

            //  add paper to a database
            Database allPapers = new Database();
            Database.addPaper(allPapers, existingPaper);

            //  search database using null keyword
            List<Paper> searchedPaper = Database.searchByKeyword(allPapers, null);

            //  check if search result returns null (found no matches for null keyword)
            Assert.AreEqual(searchedPaper, null);
        }